Search in sources :

Example 1 with SplineData

use of org.xclcharts.chart.SplineData in project XCL-Charts by xcltapestry.

the class MultiAxisChart03View method chartDataSetAxes.

private void chartDataSetAxes() {
    // 线1的数据集
    List<PointD> linePoint1 = new ArrayList<PointD>();
    linePoint1.add(new PointD(0d, 0d));
    SplineData dataSeries1 = new SplineData("", linePoint1, Color.rgb(54, 141, 238));
    dataSeries1.setDotStyle(XEnum.DotStyle.HIDE);
    // 设定数据源
    chartDataAxes.add(dataSeries1);
}
Also used : PointD(org.xclcharts.chart.PointD) ArrayList(java.util.ArrayList) SplineData(org.xclcharts.chart.SplineData)

Example 2 with SplineData

use of org.xclcharts.chart.SplineData in project XCL-Charts by xcltapestry.

the class SplineChart03View 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;
            float r = record.getRadius();
            chart.showFocusPointF(record.getPosition(), r + r * 0.8f);
            chart.getFocusPaint().setStyle(Style.FILL);
            chart.getFocusPaint().setStrokeWidth(3);
            if (record.getDataID() >= 2) {
                chart.getFocusPaint().setColor(Color.BLUE);
            } else {
                chart.getFocusPaint().setColor(Color.RED);
            }
            // 在点击处显示tooltip
            mPaintTooltips.setColor(Color.RED);
            chart.getToolTip().setCurrentXY(x, y);
            chart.getToolTip().addToolTip(" Key:" + lData.getLineKey(), mPaintTooltips);
            chart.getToolTip().addToolTip(" Current Value:" + Double.toString(xValue) + "," + Double.toString(yValue), mPaintTooltips);
            chart.getToolTip().getBackgroundPaint().setAlpha(100);
            this.invalidate();
            break;
        }
        i++;
    }
// end while
}
Also used : PointD(org.xclcharts.chart.PointD) Iterator(java.util.Iterator) SplineData(org.xclcharts.chart.SplineData) PointPosition(org.xclcharts.event.click.PointPosition) Paint(android.graphics.Paint)

Example 3 with SplineData

use of org.xclcharts.chart.SplineData in project XCL-Charts by xcltapestry.

the class SplineChart03View 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));
    linePoint1.add(new PointD(75d, 43d));
    linePoint1.add(new PointD(82d, 55d));
    linePoint1.add(new PointD(90d, 60d));
    linePoint1.add(new PointD(96d, 68d));
    SplineData dataSeries1 = new SplineData("线一", linePoint1, Color.rgb(54, 141, 238));
    // 把线弄细点
    dataSeries1.getLinePaint().setStrokeWidth(2);
    dataSeries1.setLabelVisible(true);
    // 线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.setDotStyle(XEnum.DotStyle.RING);
    // dataSeries2.getDotLabelPaint().setColor(Color.RED);
    // 线2的数据集
    List<PointD> linePoint3 = new ArrayList<PointD>();
    linePoint3.add(new PointD(30d, 60d));
    linePoint3.add(new PointD(45d, 65d));
    linePoint3.add(new PointD(50d, 75d));
    linePoint3.add(new PointD(65d, 95d));
    SplineData dataSeries3 = new SplineData("线三", linePoint3, Color.rgb(84, 206, 231));
    dataSeries3.setDotStyle(XEnum.DotStyle.RING);
    dataSeries3.getDotPaint().setColor(Color.rgb(75, 166, 51));
    dataSeries3.getPlotLine().getPlotDot().setRingInnerColor(Color.rgb(123, 89, 168));
    // 设定数据源
    chartData.add(dataSeries1);
    chartData.add(dataSeries2);
    chartData.add(dataSeries3);
}
Also used : PointD(org.xclcharts.chart.PointD) ArrayList(java.util.ArrayList) SplineData(org.xclcharts.chart.SplineData)

Example 4 with SplineData

use of org.xclcharts.chart.SplineData in project XCL-Charts by xcltapestry.

the class SplineChart05View 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(4d, 15d));
    linePoint1.add(new PointD(5d, 16d));
    SplineData dataSeries1 = new SplineData("Go", linePoint1, // Color.rgb(54, 141, 238)
    Color.WHITE);
    // 把线弄细点
    dataSeries1.getLinePaint().setStrokeWidth(6);
    dataSeries1.setLineStyle(XEnum.LineStyle.DASH);
    dataSeries1.setLabelVisible(false);
    dataSeries1.setDotStyle(XEnum.DotStyle.RING);
    dataSeries1.getDotPaint().setColor(Color.rgb(30, 179, 143));
    // 
    dataSeries1.getPlotLine().getPlotDot().setRingInnerColor(Color.WHITE);
    chartData.add(dataSeries1);
}
Also used : PointD(org.xclcharts.chart.PointD) ArrayList(java.util.ArrayList) SplineData(org.xclcharts.chart.SplineData)

Example 5 with SplineData

use of org.xclcharts.chart.SplineData in project XCL-Charts by xcltapestry.

the class SplineChart05View 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.getFocusPaint().setStyle(Style.FILL);
                chart.getFocusPaint().setStrokeWidth(6);
                chart.getFocusPaint().setColor(Color.rgb(237, 92, 92));
                chart.showFocusPointF(record.getPosition(), r * 2);
                /*
						//在点击处显示tooltip
						pToolTip.setColor(Color.RED);	
						pToolTip.setStrokeWidth(3);
						chart.getToolTip().setCurrentXY(x,y);
						//chart.getToolTip().setRoundRadius(x, y);
						chart.getToolTip().setStyle(XEnum.DyInfoStyle.CIRCLE);
						chart.getToolTip().addToolTip("",pToolTip);
						*/
                this.invalidate();
                break;
            }
            i++;
        }
    // end while
    }
}
Also used : PointD(org.xclcharts.chart.PointD) Iterator(java.util.Iterator) SplineData(org.xclcharts.chart.SplineData) PointPosition(org.xclcharts.event.click.PointPosition) Paint(android.graphics.Paint) AnchorDataPoint(org.xclcharts.renderer.info.AnchorDataPoint)

Aggregations

PointD (org.xclcharts.chart.PointD)11 SplineData (org.xclcharts.chart.SplineData)11 ArrayList (java.util.ArrayList)7 Iterator (java.util.Iterator)4 PointPosition (org.xclcharts.event.click.PointPosition)4 Paint (android.graphics.Paint)3 AnchorDataPoint (org.xclcharts.renderer.info.AnchorDataPoint)2