use of org.xclcharts.chart.SplineData in project XCL-Charts by xcltapestry.
the class QuadrantChart01View method chartDataSetSp.
private void chartDataSetSp() {
// 线1的数据集
List<PointD> linePoint1 = new ArrayList<PointD>();
linePoint1.add(new PointD(25d, 15d));
linePoint1.add(new PointD(45d, 35d));
linePoint1.add(new PointD(50d, 40d));
linePoint1.add(new PointD(65d, 45d));
linePoint1.add(new PointD(70d, 50d));
linePoint1.add(new PointD(75d, 65d));
linePoint1.add(new PointD(85d, 73d));
linePoint1.add(new PointD(92d, 85d));
SplineData dataSeries1 = new SplineData("指向线", linePoint1, // (int)Color.rgb(54, 141, 238)
Color.RED);
// 把线弄细点
dataSeries1.getLinePaint().setStrokeWidth(10);
dataSeries1.setDotStyle(XEnum.DotStyle.HIDE);
// 设定数据源
chartDataSp.add(dataSeries1);
}
use of org.xclcharts.chart.SplineData in project XCL-Charts by xcltapestry.
the class SplineChart02View method triggerClick.
// 触发监听
private void triggerClick(float x, float y) {
if (!chart.getListenItemClickStatus())
return;
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;
Toast.makeText(this.getContext(), record.getPointInfo() + " Key:" + lData.getLineKey() + " Current Value(key,value):" + Double.toString(xValue) + "," + Double.toString(yValue), Toast.LENGTH_SHORT).show();
break;
}
i++;
}
// end while
}
use of org.xclcharts.chart.SplineData in project XCL-Charts by xcltapestry.
the class SplineChart02View method chartDataSet.
private void chartDataSet() {
List<PointD> lineSin = new ArrayList<PointD>();
List<PointD> lineCos = new ArrayList<PointD>();
int step = 2;
int count = 360 / step + 1;
for (int i = 0; i < count; i++) {
int angle = i * step;
double rAngle = Math.toRadians(angle);
lineSin.add(new PointD(angle, Math.sin(rAngle)));
lineCos.add(new PointD(angle, Math.cos(rAngle)));
}
SplineData dataSeriesSin = new SplineData("Sin", lineSin, Color.rgb(54, 141, 238));
SplineData dataSeriesCos = new SplineData("Cos", lineCos, Color.rgb(255, 165, 132));
dataSeriesSin.setDotStyle(XEnum.DotStyle.HIDE);
dataSeriesCos.setDotStyle(XEnum.DotStyle.HIDE);
// 设定数据源
chartData.add(dataSeriesSin);
chartData.add(dataSeriesCos);
}
use of org.xclcharts.chart.SplineData in project XCL-Charts by xcltapestry.
the class SplineChart04View method chartDataSet.
private void chartDataSet() {
// 线1的数据集
List<PointD> linePoint1 = new ArrayList<PointD>();
linePoint1.add(new PointD(0d, 3d));
linePoint1.add(new PointD(1d, 9d));
linePoint1.add(new PointD(2d, 8d));
linePoint1.add(new PointD(3d, 7d));
linePoint1.add(new PointD(6d, 15d));
SplineData dataSeries1 = new SplineData("Go", linePoint1, Color.rgb(54, 141, 238));
// 把线弄细点
dataSeries1.getLinePaint().setStrokeWidth(3);
dataSeries1.setLineStyle(XEnum.LineStyle.DASH);
dataSeries1.setLabelVisible(false);
dataSeries1.setDotStyle(XEnum.DotStyle.HIDE);
// 线2的数据集
List<PointD> linePoint2 = new ArrayList<PointD>();
linePoint2.add(new PointD(0d, 10d));
linePoint2.add(new PointD(1d, 13d));
linePoint2.add(new PointD(2d, 16d));
linePoint2.add(new PointD(3d, 15d));
linePoint2.add(new PointD(6d, 18d));
SplineData dataSeries2 = new SplineData("C/C++", linePoint2, Color.rgb(255, 165, 132));
dataSeries2.setLabelVisible(false);
dataSeries2.setDotStyle(XEnum.DotStyle.HIDE);
// 线2的数据集
List<PointD> linePoint3 = new ArrayList<PointD>();
linePoint3.add(new PointD(0d, 8d));
linePoint3.add(new PointD(1d, 13d));
linePoint3.add(new PointD(2d, 11d));
linePoint3.add(new PointD(3d, 15d));
linePoint3.add(new PointD(6d, 16d));
SplineData dataSeries3 = new SplineData("Java", linePoint3, Color.rgb(77, 184, 73));
dataSeries3.setLabelVisible(false);
dataSeries3.setDotStyle(XEnum.DotStyle.HIDE);
chartData.add(dataSeries1);
chartData.add(dataSeries2);
chartData.add(dataSeries3);
}
use of org.xclcharts.chart.SplineData 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
}
}
Aggregations