Search in sources :

Example 1 with BarData

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

the class BarChart07View method chartDataSet.

private void chartDataSet() {
    // 标签对应的柱形数据集
    List<Double> dataSeriesA = new LinkedList<Double>();
    // 依数据值确定对应的柱形颜色.
    List<Integer> dataColorA = new LinkedList<Integer>();
    int max = 35;
    int min = 15;
    for (int i = 1; i < 35; i++) {
        Random random = new Random();
        int v = random.nextInt(max) % (max - min + 1) + min;
        dataSeriesA.add((double) v);
        if (// 适中
        v <= 18.5d) {
            dataColorA.add(Color.rgb(77, 184, 73));
        } else if (v <= 24d) {
            // 超重
            dataColorA.add(Color.rgb(252, 210, 9));
        } else if (v <= 27.9d) {
            // 偏胖
            dataColorA.add(Color.rgb(171, 42, 96));
        } else {
            // 肥胖
            dataColorA.add(Color.RED);
        }
    }
    // 此地的颜色为Key值颜色及柱形的默认颜色
    BarData BarDataA = new BarData("", dataSeriesA, dataColorA, Color.rgb(53, 169, 239));
    chartData.add(BarDataA);
}
Also used : Random(java.util.Random) BarData(org.xclcharts.chart.BarData) LinkedList(java.util.LinkedList) SuppressLint(android.annotation.SuppressLint)

Example 2 with BarData

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

the class BarChart08View method chartDataSet.

private void chartDataSet() {
    // 标签对应的柱形数据集
    List<Double> dataSeriesA = new LinkedList<Double>();
    // 依数据值确定对应的柱形颜色.
    List<Integer> dataColorA = new LinkedList<Integer>();
    int max = 35;
    int min = -15;
    for (int i = 1; i < 10; i++) {
        Random random = new Random();
        int v = random.nextInt(max) % (max - min + 1) + min;
        dataSeriesA.add((double) v);
        if (// 适中
        v <= -5d) {
            dataColorA.add(Color.rgb(77, 184, 73));
        } else if (v <= 5d) {
            // 超重
            dataColorA.add(Color.rgb(252, 210, 9));
        } else if (v <= 10d) {
            // 偏胖
            dataColorA.add(Color.rgb(171, 42, 96));
        } else {
            // 肥胖
            dataColorA.add(Color.RED);
        }
    }
    // 此地的颜色为Key值颜色及柱形的默认颜色
    BarData BarDataA = new BarData("", dataSeriesA, dataColorA, Color.rgb(53, 169, 239));
    chartData.add(BarDataA);
}
Also used : Random(java.util.Random) BarData(org.xclcharts.chart.BarData) LinkedList(java.util.LinkedList) Paint(android.graphics.Paint)

Example 3 with BarData

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

the class BarChart10View method triggerClick.

// 触发监听
private void triggerClick(float x, float y) {
    BarPosition record = chart.getPositionRecord(x, y);
    if (null == record)
        return;
    BarData bData = chartData.get(record.getDataID());
    Double bValue = bData.getDataSet().get(record.getDataChildID());
    Toast.makeText(this.getContext(), "info:" + record.getRectInfo() + " Key:" + bData.getKey() + " Current Value:" + Double.toString(bValue), Toast.LENGTH_SHORT).show();
    chart.showFocusRectF(record.getRectF());
    chart.getFocusPaint().setStyle(Style.STROKE);
    chart.getFocusPaint().setStrokeWidth(3);
    chart.getFocusPaint().setColor(Color.GREEN);
    this.invalidate();
}
Also used : BarData(org.xclcharts.chart.BarData) BarPosition(org.xclcharts.event.click.BarPosition)

Example 4 with BarData

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

the class BarChart10View method chartDataSet.

private void chartDataSet() {
    // 标签对应的柱形数据集
    List<Double> dataSeriesA = new LinkedList<Double>();
    // 依数据值确定对应的柱形颜色.
    List<Integer> dataColorA = new LinkedList<Integer>();
    dataSeriesA.add((double) 70);
    dataColorA.add(Color.rgb(171, 42, 96));
    dataSeriesA.add((double) 85);
    dataColorA.add(Color.rgb(171, 42, 96));
    dataSeriesA.add((double) 90);
    dataColorA.add(Color.rgb(171, 42, 96));
    dataSeriesA.add((double) 102);
    dataColorA.add(Color.rgb(171, 42, 96));
    dataSeriesA.add((double) 140);
    dataColorA.add(Color.rgb(171, 42, 96));
    // ///////
    dataSeriesA.add((double) 155);
    dataColorA.add(Color.rgb(252, 210, 9));
    dataSeriesA.add((double) 155);
    dataColorA.add(Color.rgb(171, 42, 96));
    dataSeriesA.add((double) 160);
    dataColorA.add(Color.rgb(171, 42, 96));
    dataSeriesA.add((double) 200);
    dataColorA.add(Color.rgb(77, 184, 73));
    dataSeriesA.add((double) 230);
    dataColorA.add(Color.rgb(171, 42, 96));
    // /
    // 此地的颜色为Key值颜色及柱形的默认颜色
    BarData BarDataA = new BarData("", dataSeriesA, dataColorA, Color.rgb(53, 169, 239));
    chartData.add(BarDataA);
}
Also used : BarData(org.xclcharts.chart.BarData) LinkedList(java.util.LinkedList)

Example 5 with BarData

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

the class BarChart3D01View method chartDataSet.

private void chartDataSet() {
    // 标签对应的柱形数据集
    List<Double> dataSeriesA = new LinkedList<Double>();
    dataSeriesA.add(200d);
    dataSeriesA.add(250d);
    dataSeriesA.add(400d);
    dataSeriesA.add(450d);
    dataSeriesA.add(150d);
    List<Double> dataSeriesB = new LinkedList<Double>();
    dataSeriesB.add(300d);
    dataSeriesB.add(150d);
    dataSeriesB.add(450d);
    dataSeriesB.add(480d);
    dataSeriesB.add(200d);
    BarDataset.add(new BarData("左边店", dataSeriesA, Color.rgb(252, 210, 9)));
    BarDataset.add(new BarData("右边店", dataSeriesB, Color.rgb(55, 144, 206)));
    List<Double> dataSeriesC = new LinkedList<Double>();
    dataSeriesC.add(270d);
    dataSeriesC.add(180d);
    // dataSeriesC.add(450d);
    // dataSeriesC.add(380d);
    // dataSeriesC.add(230d);
    BarDataset.add(new BarData("右边店2", dataSeriesC, Color.rgb(155, 144, 206)));
}
Also used : BarData(org.xclcharts.chart.BarData) LinkedList(java.util.LinkedList)

Aggregations

BarData (org.xclcharts.chart.BarData)36 LinkedList (java.util.LinkedList)25 BarPosition (org.xclcharts.event.click.BarPosition)9 Random (java.util.Random)4 Paint (android.graphics.Paint)2 SuppressLint (android.annotation.SuppressLint)1 ArrayList (java.util.ArrayList)1 PlotDot (org.xclcharts.renderer.line.PlotDot)1