Search in sources :

Example 1 with LineData

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

the class LineChart01View method triggerClick.

//触发监听
private void triggerClick(float x, float y) {
    //交叉线
    if (chart.getDyLineVisible())
        chart.getDyLine().setCurrentXY(x, y);
    if (!chart.getListenItemClickStatus()) {
        //交叉线
        if (chart.getDyLineVisible())
            this.invalidate();
    } else {
        PointPosition record = chart.getPositionRecord(x, y);
        if (null == record) {
            if (chart.getDyLineVisible())
                this.invalidate();
            return;
        }
        LineData lData = chartData.get(record.getDataID());
        Double lValue = lData.getLinePoint().get(record.getDataChildID());
        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.BLUE);
        } else {
            chart.getFocusPaint().setColor(Color.RED);
        }
        //在点击处显示tooltip
        mPaintTooltips.setColor(Color.RED);
        //chart.getToolTip().setCurrentXY(x,y);
        chart.getToolTip().setCurrentXY(record.getPosition().x, record.getPosition().y);
        chart.getToolTip().addToolTip(" Key:" + lData.getLineKey(), mPaintTooltips);
        chart.getToolTip().addToolTip(" Label:" + lData.getLabel(), mPaintTooltips);
        chart.getToolTip().addToolTip(" Current Value:" + Double.toString(lValue), mPaintTooltips);
        //当前标签对应的其它点的值
        int cid = record.getDataChildID();
        String xLabels = "";
        for (LineData data : chartData) {
            if (cid < data.getLinePoint().size()) {
                xLabels = Double.toString(data.getLinePoint().get(cid));
                chart.getToolTip().addToolTip("Line:" + data.getLabel() + "," + xLabels, mPaintTooltips);
            }
        }
        this.invalidate();
    }
}
Also used : LineData(org.xclcharts.chart.LineData) PointPosition(org.xclcharts.event.click.PointPosition) Paint(android.graphics.Paint)

Example 2 with LineData

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

the class LineChart01View method chartDataSet.

private void chartDataSet() {
    //Line 1
    LinkedList<Double> dataSeries1 = new LinkedList<Double>();
    dataSeries1.add(20d);
    dataSeries1.add(10d);
    dataSeries1.add(31d);
    dataSeries1.add(40d);
    dataSeries1.add(0d);
    LineData lineData1 = new LineData("方块", dataSeries1, Color.rgb(234, 83, 71));
    lineData1.setLabelVisible(true);
    lineData1.setDotStyle(XEnum.DotStyle.RECT);
    lineData1.getDotLabelPaint().setColor(Color.BLUE);
    lineData1.getDotLabelPaint().setTextSize(22);
    lineData1.getDotLabelPaint().setTextAlign(Align.LEFT);
    lineData1.setItemLabelRotateAngle(45.f);
    lineData1.getLabelOptions().setLabelBoxStyle(XEnum.LabelBoxStyle.TEXT);
    //lineData1.getLabelOptions().
    //lineData1.setDataSet(dataSeries);
    //this.invalidate();
    //Line 2
    LinkedList<Double> dataSeries2 = new LinkedList<Double>();
    dataSeries2.add((double) 30);
    dataSeries2.add((double) 42);
    dataSeries2.add((double) 0);
    dataSeries2.add((double) 60);
    dataSeries2.add((double) 40);
    LineData lineData2 = new LineData("圆环", dataSeries2, Color.rgb(75, 166, 51));
    lineData2.setDotStyle(XEnum.DotStyle.RING);
    lineData2.getPlotLine().getDotPaint().setColor(Color.RED);
    lineData2.setLabelVisible(true);
    lineData2.getPlotLine().getPlotDot().setRingInnerColor(Color.GREEN);
    lineData2.setLineStyle(XEnum.LineStyle.DASH);
    // 设置点大小
    //lineData2.getPlotLine().getPlotDot().setDotRadius(radius);
    //Line 3
    LinkedList<Double> dataSeries3 = new LinkedList<Double>();
    dataSeries3.add(65d);
    dataSeries3.add(75d);
    dataSeries3.add(55d);
    dataSeries3.add(65d);
    dataSeries3.add(95d);
    LineData lineData3 = new LineData("圆点", dataSeries3, Color.rgb(123, 89, 168));
    lineData3.setDotStyle(XEnum.DotStyle.DOT);
    lineData3.setDotRadius(20);
    //lineData3.setLabelVisible(true);
    //lineData3.getDotLabelPaint().setTextAlign(Align.CENTER);				
    //Line 4
    LinkedList<Double> dataSeries4 = new LinkedList<Double>();
    dataSeries4.add(50d);
    dataSeries4.add(60d);
    dataSeries4.add(80d);
    dataSeries4.add(84d);
    dataSeries4.add(90d);
    LineData lineData4 = new LineData("棱形", dataSeries4, Color.rgb(84, 206, 231));
    lineData4.setDotStyle(XEnum.DotStyle.PRISMATIC);
    //把线弄细点
    lineData4.getLinePaint().setStrokeWidth(2);
    lineData4.getLabelOptions().setLabelBoxStyle(XEnum.LabelBoxStyle.CIRCLE);
    lineData4.getLabelOptions().getBox().getBackgroundPaint().setColor(Color.GREEN);
    lineData4.setLabelVisible(true);
    //Line 5
    LinkedList<Double> valuesE = new LinkedList<Double>();
    valuesE.add(0d);
    valuesE.add(80d);
    valuesE.add(85d);
    valuesE.add(90d);
    LineData lineData5 = new LineData("定制", valuesE, Color.rgb(234, 142, 43));
    lineData5.setDotRadius(15);
    lineData5.setDotStyle(XEnum.DotStyle.TRIANGLE);
    //Line 2
    LinkedList<Double> dataSeries6 = new LinkedList<Double>();
    dataSeries6.add((double) 50);
    dataSeries6.add((double) 52);
    dataSeries6.add((double) 53);
    dataSeries6.add((double) 55);
    dataSeries6.add((double) 40);
    LineData lineData6 = new LineData("圆环2", dataSeries6, Color.rgb(75, 166, 51));
    lineData6.setDotStyle(XEnum.DotStyle.RING2);
    lineData6.getPlotLine().getDotPaint().setColor(Color.RED);
    lineData6.setLabelVisible(true);
    //lineData6.getPlotLine().getPlotDot().setRingInnerColor(Color.GREEN);
    //lineData6.getPlotLine().getPlotDot().setRing2InnerColor(Color.GREEN);
    //lineData6.setLineStyle(XEnum.LineStyle.DASH);
    lineData6.getDotLabelPaint().setColor(Color.rgb(212, 64, 39));
    lineData6.getLabelOptions().getBox().getBackgroundPaint().setColor(Color.rgb(57, 172, 241));
    lineData6.getLabelOptions().getBox().setBorderLineColor(Color.YELLOW);
    chartData.add(lineData1);
    chartData.add(lineData2);
    chartData.add(lineData3);
    chartData.add(lineData4);
    chartData.add(lineData5);
    chartData.add(lineData6);
}
Also used : LineData(org.xclcharts.chart.LineData) LinkedList(java.util.LinkedList)

Example 3 with LineData

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

the class LineChart03View method chartDataSet.

private void chartDataSet() {
    //Line 1
    LinkedList<Double> dataSeries1 = new LinkedList<Double>();
    dataSeries1.add(20d);
    dataSeries1.add(10d);
    dataSeries1.add(31d);
    dataSeries1.add(40d);
    dataSeries1.add(0d);
    LineData lineData1 = new LineData("方块", dataSeries1, Color.rgb(234, 83, 71));
    lineData1.setLabelVisible(true);
    lineData1.setDotStyle(XEnum.DotStyle.RECT);
    lineData1.getDotLabelPaint().setColor(Color.BLUE);
    lineData1.getDotLabelPaint().setTextSize(22);
    lineData1.getDotLabelPaint().setTextAlign(Align.LEFT);
    //Line 2
    LinkedList<Double> dataSeries2 = new LinkedList<Double>();
    dataSeries2.add((double) 30);
    dataSeries2.add((double) 42);
    dataSeries2.add((double) 50);
    dataSeries2.add((double) 60);
    dataSeries2.add((double) 40);
    LineData lineData2 = new LineData("圆环", dataSeries2, Color.rgb(75, 166, 51));
    lineData2.setDotStyle(XEnum.DotStyle.RING);
    lineData2.getPlotLine().getDotPaint().setColor(Color.BLACK);
    lineData2.setLabelVisible(true);
    //Line 3
    LinkedList<Double> dataSeries3 = new LinkedList<Double>();
    dataSeries3.add(65d);
    dataSeries3.add(75d);
    dataSeries3.add(55d);
    dataSeries3.add(65d);
    dataSeries3.add(95d);
    LineData lineData3 = new LineData("圆点", dataSeries3, Color.rgb(123, 89, 168));
    lineData3.setDotStyle(XEnum.DotStyle.DOT);
    //Line 4
    LinkedList<Double> dataSeries4 = new LinkedList<Double>();
    dataSeries4.add(50d);
    dataSeries4.add(60d);
    dataSeries4.add(80d);
    dataSeries4.add(84d);
    dataSeries4.add(90d);
    LineData lineData4 = new LineData("棱形", dataSeries4, Color.rgb(84, 206, 231));
    lineData4.setDotStyle(XEnum.DotStyle.PRISMATIC);
    //Line 5
    LinkedList<Double> valuesE = new LinkedList<Double>();
    valuesE.add(0d);
    valuesE.add(80d);
    valuesE.add(85d);
    valuesE.add(90d);
    LineData lineData5 = new LineData("定制", valuesE, Color.rgb(234, 142, 43));
    lineData5.setDotRadius(15);
    chartData.add(lineData1);
    chartData.add(lineData2);
    chartData.add(lineData3);
    chartData.add(lineData4);
    chartData.add(lineData5);
}
Also used : LineData(org.xclcharts.chart.LineData) LinkedList(java.util.LinkedList)

Example 4 with LineData

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

the class LineChart03View_left method chartDataSet.

private void chartDataSet() {
    LinkedList<Double> dataSeries1 = new LinkedList<Double>();
    dataSeries1.add(-100d);
    LineData lineData1 = new LineData("方块", dataSeries1, Color.rgb(234, 83, 71));
    //chartData.add(lineData1);
    lineData1.setLabelVisible(false);
    //lineData1.setDotStyle(XEnum.DotStyle.HIDE);
    //Line 2
    LinkedList<Double> dataSeries2 = new LinkedList<Double>();
    dataSeries2.add(-100d);
    LineData lineData2 = new LineData("圆环", dataSeries2, Color.rgb(75, 166, 51));
    lineData2.setDotStyle(XEnum.DotStyle.RING);
    lineData2.getPlotLine().getDotPaint().setColor(Color.BLACK);
    lineData2.setLabelVisible(false);
    //lineData2.setDotStyle(XEnum.DotStyle.HIDE);
    //Line 3
    LinkedList<Double> dataSeries3 = new LinkedList<Double>();
    dataSeries3.add(-100d);
    LineData lineData3 = new LineData("圆点", dataSeries3, Color.rgb(123, 89, 168));
    lineData3.setDotStyle(XEnum.DotStyle.DOT);
    lineData3.setLabelVisible(false);
    //lineData3.setDotStyle(XEnum.DotStyle.HIDE);
    //Line 4
    LinkedList<Double> dataSeries4 = new LinkedList<Double>();
    dataSeries4.add(-100d);
    LineData lineData4 = new LineData("棱形", dataSeries4, Color.rgb(84, 206, 231));
    lineData4.setDotStyle(XEnum.DotStyle.PRISMATIC);
    lineData4.setLabelVisible(false);
    //lineData4.setDotStyle(XEnum.DotStyle.HIDE);
    //Line 5
    LinkedList<Double> valuesE = new LinkedList<Double>();
    valuesE.add(-100d);
    LineData lineData5 = new LineData("定制", valuesE, Color.rgb(234, 142, 43));
    lineData5.setDotRadius(15);
    lineData5.setLabelVisible(false);
    //lineData5.setDotStyle(XEnum.DotStyle.HIDE);
    chartData.add(lineData1);
    chartData.add(lineData2);
    chartData.add(lineData3);
    chartData.add(lineData4);
    chartData.add(lineData5);
}
Also used : LineData(org.xclcharts.chart.LineData) LinkedList(java.util.LinkedList)

Example 5 with LineData

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

the class MultiAxisChart01View method chartLnDataSet.

private void chartLnDataSet() {
    //用于在key上显示柱形的Key
    LinkedList<Double> BarKey1 = new LinkedList<Double>();
    BarKey1.add(0d);
    LinkedList<Double> BarKey2 = new LinkedList<Double>();
    BarKey2.add(0d);
    LineData lineDataBarKey1 = new LineData("Virtual OPM", BarKey1, Color.rgb(0, 221, 177));
    LineData lineDataBarKey2 = new LineData("Physical OPM", BarKey2, Color.rgb(238, 28, 161));
    lineDataBarKey1.setDotStyle(XEnum.DotStyle.RECT);
    lineDataBarKey2.setDotStyle(XEnum.DotStyle.RECT);
    chartDatasetLn.add(lineDataBarKey1);
    chartDatasetLn.add(lineDataBarKey2);
    //实际的折线图的数据集
    //标签1对应的数据集
    LinkedList<Double> virtual = new LinkedList<Double>();
    //virtual.add(0d); 			
    virtual.add(95d);
    virtual.add(100d);
    //virtual.add(0d); 
    //标签2对应的数据集
    LinkedList<Double> physical = new LinkedList<Double>();
    //physical.add(0d); 
    physical.add(110d);
    physical.add(125d);
    //physical.add(0d); 
    //将标签与对应的数据集分别绑定
    LineData lineData1 = new LineData("Virtual RT", virtual, Color.rgb(234, 83, 71));
    LineData lineData2 = new LineData("Physical RT", physical, Color.rgb(75, 166, 51));
    lineData1.setDotStyle(XEnum.DotStyle.TRIANGLE);
    lineData1.getDotPaint().setColor(Color.rgb(234, 83, 71));
    chartDatasetLn.add(lineData1);
    chartDatasetLn.add(lineData2);
}
Also used : LineData(org.xclcharts.chart.LineData) LinkedList(java.util.LinkedList)

Aggregations

LineData (org.xclcharts.chart.LineData)9 LinkedList (java.util.LinkedList)8 CustomLineData (org.xclcharts.chart.CustomLineData)2 AnchorDataPoint (org.xclcharts.renderer.info.AnchorDataPoint)2 Paint (android.graphics.Paint)1 PointPosition (org.xclcharts.event.click.PointPosition)1