use of org.xclcharts.chart.PointD in project XCL-Charts by xcltapestry.
the class BubbleChart01View method triggerClick.
// 触发监听
private void triggerClick(float x, float y) {
// 交叉线
if (chart.getDyLineVisible())
chart.getDyLine().setCurrentXY(x, y);
if (!chart.getListenItemClickStatus()) {
if (chart.getDyLineVisible() && chart.getDyLine().isInvalidate())
this.invalidate();
} else {
PointPosition record = chart.getPositionRecord(x, y);
if (null == record)
return;
BubbleData lData = chartData.get(record.getDataID());
List<PointD> mapPoint = lData.getDataSet();
int pos = record.getDataChildID();
int i = 0;
Iterator it = mapPoint.iterator();
while (it.hasNext()) {
PointD entry = (PointD) it.next();
if (pos == i) {
Double xValue = entry.x;
Double yValue = entry.y;
float r = record.getRadius();
chart.showFocusPointF(record.getPosition(), r + r * 0.5f);
chart.getFocusPaint().setStyle(Style.STROKE);
chart.getFocusPaint().setStrokeWidth(3);
if (record.getDataID() >= 3) {
chart.getFocusPaint().setColor(Color.WHITE);
} else {
chart.getFocusPaint().setColor(Color.RED);
}
// 在点击处显示tooltip
mPaintTooltips.setColor(Color.WHITE);
chart.getToolTip().setCurrentXY(record.getPosition().x, record.getPosition().y);
chart.getToolTip().addToolTip(" Key:" + lData.getKey(), mPaintTooltips);
chart.getToolTip().addToolTip(Double.toString(xValue) + "," + Double.toString(yValue), mPaintTooltips);
chart.getToolTip().setStyle(XEnum.DyInfoStyle.CAPRECT);
chart.getToolTip().setAlign(Align.CENTER);
chart.getToolTip().getBackgroundPaint().setColor(Color.parseColor("#9400D3"));
this.invalidate();
break;
}
i++;
}
// end while
}
// end if
}
use of org.xclcharts.chart.PointD in project XCL-Charts by xcltapestry.
the class SplineChart01View method triggerClick.
// 触发监听
private void triggerClick(float x, float y) {
// 交叉线
if (chart.getDyLineVisible())
chart.getDyLine().setCurrentXY(x, y);
if (!chart.getListenItemClickStatus()) {
if (chart.getDyLineVisible() && chart.getDyLine().isInvalidate())
this.invalidate();
} else {
PointPosition record = chart.getPositionRecord(x, y);
if (null == record)
return;
if (record.getDataID() >= chartData.size())
return;
SplineData lData = chartData.get(record.getDataID());
List<PointD> linePoint = lData.getLineDataSet();
int pos = record.getDataChildID();
int i = 0;
Iterator it = linePoint.iterator();
while (it.hasNext()) {
PointD entry = (PointD) it.next();
if (pos == i) {
Double xValue = entry.x;
Double yValue = entry.y;
float r = record.getRadius();
chart.showFocusPointF(record.getPosition(), r * 2);
chart.getFocusPaint().setStyle(Style.STROKE);
chart.getFocusPaint().setStrokeWidth(3);
if (record.getDataID() >= 2) {
chart.getFocusPaint().setColor(Color.BLUE);
} else {
chart.getFocusPaint().setColor(Color.RED);
}
// 在点击处显示tooltip
pToolTip.setColor(Color.RED);
chart.getToolTip().setCurrentXY(x, y);
chart.getToolTip().addToolTip(" Key:" + lData.getLineKey(), pToolTip);
chart.getToolTip().addToolTip(" Label:" + lData.getLabel(), pToolTip);
chart.getToolTip().addToolTip(" Current Value:" + Double.toString(xValue) + "," + Double.toString(yValue), pToolTip);
chart.getToolTip().getBackgroundPaint().setAlpha(100);
this.invalidate();
break;
}
i++;
}
// end while
}
}
use of org.xclcharts.chart.PointD in project XCL-Charts by xcltapestry.
the class SplineChart01View method chartDataSet.
private void chartDataSet() {
/*
//线1的数据集
List<PointD> linePoint1 = new ArrayList<PointD>();
linePoint1.add(new PointD(5d, 8d));
linePoint1.add(new PointD(12d, 12d));
linePoint1.add(new PointD(25d, 15d));
linePoint1.add(new PointD(30d, 30d));
linePoint1.add(new PointD(45d, 25d));
linePoint1.add(new PointD(55d, 33d));
linePoint1.add(new PointD(62d, 45d));
SplineData dataSeries1 = new SplineData("青菜萝卜够吃",linePoint1,
Color.rgb(54, 141, 238) );
//把线弄细点
dataSeries1.getLinePaint().setStrokeWidth(2);
//线2的数据集
List<PointD> linePoint2 = new ArrayList<PointD>();
linePoint2.add(new PointD(40d, 50d));
linePoint2.add(new PointD(55d, 55d));
linePoint2.add(new PointD(60d, 65d));
linePoint2.add(new PointD(65d, 85d));
linePoint2.add(new PointD(72d, 70d));
linePoint2.add(new PointD(85d, 68d));
SplineData dataSeries2 = new SplineData("饭管够",linePoint2,
Color.rgb(255, 165, 132) );
dataSeries2.setLabelVisible(true);
dataSeries2.setDotStyle(XEnum.DotStyle.RECT);
dataSeries2.getDotLabelPaint().setColor(Color.RED);
//设定数据源
chartData.add(dataSeries1);
chartData.add(dataSeries2);
*/
// 线1的数据集
List<PointD> linePoint1 = new ArrayList<PointD>();
linePoint1.add(new PointD(2d, 8d));
linePoint1.add(new PointD(5d, 8d));
linePoint1.add(new PointD(10d, 12d));
// linePoint1.add(new PointD(25d, 15d));
// linePoint1.add(new PointD(30d, 30d));
// linePoint1.add(new PointD(45d, 25d));
// linePoint1.add(new PointD(55d, 33d));
// linePoint1.add(new PointD(62d, 45d));
SplineData dataSeries1 = new SplineData("青菜萝卜够吃", linePoint1, Color.rgb(54, 141, 238));
// 把线弄细点
dataSeries1.getLinePaint().setStrokeWidth(2);
// 线2的数据集
List<PointD> linePoint2 = new ArrayList<PointD>();
linePoint2.add(new PointD(1d, 50d));
linePoint2.add(new PointD(2d, 52d));
linePoint2.add(new PointD(3d, 53d));
linePoint2.add(new PointD(8d, 55d));
SplineData dataSeries2 = new SplineData("饭管够", linePoint2, Color.rgb(255, 165, 132));
dataSeries2.setLabelVisible(true);
dataSeries2.setDotStyle(XEnum.DotStyle.RECT);
dataSeries2.getDotLabelPaint().setColor(Color.RED);
// 设置round风格的标签
// dataSeries2.getLabelOptions().showBackground();
dataSeries2.getLabelOptions().getBox().getBackgroundPaint().setColor(Color.GREEN);
dataSeries2.getLabelOptions().getBox().setRoundRadius(8);
dataSeries2.getLabelOptions().setLabelBoxStyle(XEnum.LabelBoxStyle.CAPROUNDRECT);
chartData.add(dataSeries1);
chartData.add(dataSeries2);
}
use of org.xclcharts.chart.PointD in project XCL-Charts by xcltapestry.
the class DySpActivity method charts.
private void charts() {
DySplineChart chartView = (DySplineChart) findViewById(R.id.ln_view);
int minY = 30;
int maxY = 100;
int minX = 10;
int maxX = 50;
Random random = new Random();
linePoint1.clear();
linePoint2.clear();
double x = random.nextInt(maxX) % (maxX - minX + 1) + minX;
double y = random.nextInt(maxY) % (maxY - minY + 1) + minY;
for (int i = 0; i < 5; i++) {
// x +=i*10;
// y +=i*10;
x += 12;
y += 10;
// linePoint1.add(new PointD(x + 50, y+50));
linePoint1.add(new PointD(x, y));
}
linePoint1.add(new PointD(45, 70));
linePoint1.add(new PointD(50, 90));
linePoint1.add(new PointD(65, 60));
linePoint2.add(new PointD(5, 10));
linePoint2.add(new PointD(18, 65));
linePoint2.add(new PointD(20, 55));
linePoint2.add(new PointD(40, 70));
chartView.refreshChart(linePoint1, linePoint2);
}
Aggregations