Search in sources :

Example 11 with PointD

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

the class ScatterChart01View method chartDataSet.

private void chartDataSet() {
    // 线1的数据集
    ArrayList<PointD> linePoint1 = new ArrayList<PointD>();
    linePoint1.add(new PointD(2d, 10d));
    linePoint1.add(new PointD(6d, 10d));
    linePoint1.add(new PointD(5d, 10d));
    linePoint1.add(new PointD(3d, 10d));
    linePoint1.add(new PointD(4d, 10d));
    ScatterData dataSeries1 = new ScatterData("青菜萝卜够吃", linePoint1, Color.rgb(54, 141, 238), XEnum.DotStyle.DOT);
    dataSeries1.setLabelVisible(true);
    dataSeries1.getDotLabelPaint().setColor(Color.rgb(191, 79, 75));
    // 线2的数据集
    ArrayList<PointD> linePoint2 = new ArrayList<PointD>();
    linePoint2.add(new PointD(2d, 5d));
    linePoint2.add(new PointD(5d, 5d));
    linePoint2.add(new PointD(6d, 5d));
    linePoint2.add(new PointD(3d, 5d));
    linePoint2.add(new PointD(7d, 5d));
    linePoint2.add(new PointD(4d, 5d));
    ScatterData dataSeries2 = new ScatterData("饭管够", linePoint2, Color.rgb(155, 187, 90), XEnum.DotStyle.PRISMATIC);
    ArrayList<PointD> linePoint3 = new ArrayList<PointD>();
    linePoint3.add(new PointD(3d, 20d));
    linePoint3.add(new PointD(5d, 20d));
    linePoint3.add(new PointD(6d, 20d));
    ScatterData dataSeries3 = new ScatterData("哈哈", linePoint3, Color.rgb(54, 141, 238), XEnum.DotStyle.RING);
    dataSeries3.setLabelVisible(true);
    dataSeries3.getPlotDot().setRingInnerColor(Color.rgb(242, 167, 69));
    dataSeries3.getDotLabelPaint().setTextAlign(Align.CENTER);
    ArrayList<PointD> linePoint4 = new ArrayList<PointD>();
    linePoint4.add(new PointD(2d, 70d));
    linePoint4.add(new PointD(3d, 79d));
    linePoint4.add(new PointD(5d, 75d));
    linePoint4.add(new PointD(7d, 75d));
    ScatterData dataSeries4 = new ScatterData("XXX", linePoint4, Color.rgb(60, 173, 213), XEnum.DotStyle.X);
    ArrayList<PointD> linePoint5 = new ArrayList<PointD>();
    linePoint5.add(new PointD(2d, 40d));
    linePoint5.add(new PointD(2d, 50d));
    linePoint5.add(new PointD(2d, 60d));
    linePoint5.add(new PointD(2.5d, 43d));
    linePoint5.add(new PointD(2.5d, 51d));
    linePoint5.add(new PointD(2.5d, 60d));
    linePoint5.add(new PointD(3d, 73d));
    linePoint5.add(new PointD(3d, 40d));
    linePoint5.add(new PointD(5d, 55d));
    linePoint5.add(new PointD(7d, 55d));
    ScatterData dataSeries5 = new ScatterData("Cross", linePoint5, Color.RED, XEnum.DotStyle.CROSS);
    // 设定数据源
    chartData.add(dataSeries1);
    chartData.add(dataSeries2);
    chartData.add(dataSeries3);
    chartData.add(dataSeries4);
    chartData.add(dataSeries5);
}
Also used : PointD(org.xclcharts.chart.PointD) ArrayList(java.util.ArrayList) ScatterData(org.xclcharts.chart.ScatterData)

Example 12 with PointD

use of org.xclcharts.chart.PointD 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);
}
Also used : PointD(org.xclcharts.chart.PointD) ArrayList(java.util.ArrayList) SplineData(org.xclcharts.chart.SplineData)

Example 13 with PointD

use of org.xclcharts.chart.PointD 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);
}
Also used : PointD(org.xclcharts.chart.PointD) ArrayList(java.util.ArrayList) SplineData(org.xclcharts.chart.SplineData)

Example 14 with PointD

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

the class QuadrantChart01View 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);
                }
                this.invalidate();
                break;
            }
            i++;
        }
    // end while
    }
// end if
}
Also used : BubbleData(org.xclcharts.chart.BubbleData) PointD(org.xclcharts.chart.PointD) Iterator(java.util.Iterator) PointPosition(org.xclcharts.event.click.PointPosition)

Example 15 with PointD

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

the class BubbleChart01View 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));
    // 气泡大小
    ArrayList<Double> linePoint1_bubble = new ArrayList<Double>();
    linePoint1_bubble.add(55d);
    linePoint1_bubble.add(60d);
    linePoint1_bubble.add(65d);
    linePoint1_bubble.add(95d);
    linePoint1_bubble.add(75d);
    linePoint1_bubble.add(78d);
    BubbleData dataSeries1 = new BubbleData("青菜萝卜够吃", linePoint1, linePoint1_bubble, Color.rgb(54, 141, 238));
    dataSeries1.setLabelVisible(true);
    dataSeries1.getDotLabelPaint().setTextAlign(Align.CENTER);
    dataSeries1.setBorderColor(Color.RED);
    // 线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));
    ArrayList<Double> linePoint2_bubble = new ArrayList<Double>();
    linePoint2_bubble.add(55d);
    linePoint2_bubble.add(60d);
    linePoint2_bubble.add(65d);
    linePoint2_bubble.add(95d);
    linePoint2_bubble.add(75d);
    linePoint2_bubble.add(78d);
    BubbleData dataSeries2 = new BubbleData("饭管够", linePoint2, linePoint2_bubble, Color.rgb(255, 165, 132));
    // dataSeries2.setBorderColor(Color.BLUE);
    dataSeries2.setLabelVisible(true);
    // dataSeries2.setDotStyle(XEnum.DotStyle.RECT);
    dataSeries2.getDotLabelPaint().setColor(Color.rgb(69, 199, 101));
    dataSeries2.setItemLabelRotateAngle(45.f);
    List<PointD> linePoint3 = new ArrayList<PointD>();
    linePoint3.add(new PointD(10d, 70d));
    linePoint3.add(new PointD(25d, 85d));
    linePoint3.add(new PointD(30d, 95d));
    ArrayList<Double> linePoint3_bubble = new ArrayList<Double>();
    linePoint3_bubble.add(55d);
    linePoint3_bubble.add(60d);
    linePoint3_bubble.add(65d);
    BubbleData dataSeries3 = new BubbleData("钱不够花", linePoint2, linePoint3_bubble, Color.rgb(247, 178, 79));
    dataSeries3.setBorderColor(Color.rgb(47, 254, 225));
    // 设定数据源
    chartData.add(dataSeries1);
    chartData.add(dataSeries2);
    chartData.add(dataSeries3);
}
Also used : BubbleData(org.xclcharts.chart.BubbleData) PointD(org.xclcharts.chart.PointD) ArrayList(java.util.ArrayList)

Aggregations

PointD (org.xclcharts.chart.PointD)19 ArrayList (java.util.ArrayList)11 SplineData (org.xclcharts.chart.SplineData)11 Iterator (java.util.Iterator)7 PointPosition (org.xclcharts.event.click.PointPosition)7 Paint (android.graphics.Paint)5 BubbleData (org.xclcharts.chart.BubbleData)4 ScatterData (org.xclcharts.chart.ScatterData)3 AnchorDataPoint (org.xclcharts.renderer.info.AnchorDataPoint)2 DySplineChart (com.demo.xclcharts.view.DySplineChart)1 Random (java.util.Random)1