Search in sources :

Example 31 with BarData

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

the class BarChart02View method chartDataSet.

private void chartDataSet() {
    // 标签对应的柱形数据集
    List<Double> dataSeriesA = new LinkedList<Double>();
    dataSeriesA.add((double) 200);
    dataSeriesA.add((double) 250);
    dataSeriesA.add((double) 400);
    BarData BarDataA = new BarData("小熊", dataSeriesA, Color.rgb(0, 0, 255));
    List<Double> dataSeriesB = new LinkedList<Double>();
    dataSeriesB.add((double) 300);
    dataSeriesB.add((double) 150);
    dataSeriesB.add((double) 450);
    BarData BarDataB = new BarData("小周", dataSeriesB, Color.rgb(255, 0, 0));
    chartData.add(BarDataA);
    chartData.add(BarDataB);
}
Also used : BarData(org.xclcharts.chart.BarData) LinkedList(java.util.LinkedList)

Example 32 with BarData

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

the class BarChart04View 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 < 31; 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)

Example 33 with BarData

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

the class BarChart06View method chartDataSet.

private void chartDataSet() {
    // 标签对应的柱形数据集
    int max = 96;
    int min = 15;
    for (int i = 0; i < arrColorRgb.length; i++) {
        List<Double> dataSeries = new LinkedList<Double>();
        for (int j = 0; j < labelsNumber; j++) {
            Random random = new Random();
            int num = random.nextInt(max) % (max - min + 1) + min;
            dataSeries.add((double) num);
        }
        BarData barData = new BarData("柱形渐显动画", dataSeries, Color.rgb(arrColorRgb[i][0], arrColorRgb[i][1], arrColorRgb[i][2]));
        chartData.add(barData);
    }
}
Also used : Random(java.util.Random) BarData(org.xclcharts.chart.BarData) LinkedList(java.util.LinkedList)

Example 34 with BarData

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

the class BarChart09View 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 35 with BarData

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

the class BarChart11View 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)

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