Search in sources :

Example 11 with PieData

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

the class PieChart02View method chartAnimation.

private void chartAnimation() {
    try {
        float sum = 0.0f;
        int count = chartData.size();
        for (int i = 0; i < count; i++) {
            Thread.sleep(150);
            ArrayList<PieData> animationData = new ArrayList<PieData>();
            sum = 0.0f;
            for (int j = 0; j <= i; j++) {
                animationData.add(chartData.get(j));
                sum = (float) MathHelper.getInstance().add(sum, chartData.get(j).getPercentage());
            }
            animationData.add(new PieData("", "", MathHelper.getInstance().sub(100.0f, sum), Color.argb(1, 0, 0, 0)));
            chart.setDataSource(animationData);
            // 激活点击监听
            if (count - 1 == i) {
                // chart.ActiveListenItemClick();
                // 显示边框线,并设置其颜色
                // chart.getArcBorderPaint().setColor(Color.YELLOW);
                // chart.getArcBorderPaint().setStrokeWidth(3);
                // 激活点击监听
                chart.ActiveListenItemClick();
                chart.showClikedFocus();
                chart.disablePanMode();
                // 显示图例
                PlotLegend legend = chart.getPlotLegend();
                legend.show();
                legend.setHorizontalAlign(XEnum.HorizontalAlign.CENTER);
                legend.setVerticalAlign(XEnum.VerticalAlign.BOTTOM);
                legend.showBox();
            }
            postInvalidate();
        }
    } catch (Exception e) {
        Thread.currentThread().interrupt();
    }
}
Also used : ArrayList(java.util.ArrayList) PieData(org.xclcharts.chart.PieData) PlotLegend(org.xclcharts.renderer.plot.PlotLegend) Paint(android.graphics.Paint)

Example 12 with PieData

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

the class CircleChart01View method setPercentage.

// 百分比
public void setPercentage(int per) {
    if (per < 50) {
        mDataInfo = "轻松搞定";
        chart.getLabelPaint().setColor(Color.WHITE);
        chart.getDataInfoPaint().setColor(Color.WHITE);
    } else if (per < 70) {
        mDataInfo = "充满活力";
        chart.getLabelPaint().setColor(Color.rgb(72, 201, 176));
        chart.getDataInfoPaint().setColor(Color.WHITE);
    } else {
        mDataInfo = "不堪重负";
        chart.getLabelPaint().setColor(Color.RED);
        chart.getDataInfoPaint().setColor(Color.RED);
    }
    // PieData(标签,百分比,在饼图中对应的颜色)
    mlPieData.clear();
    mlPieData.add(new PieData(Integer.toString(per) + "%", per, Color.rgb(72, 201, 176)));
}
Also used : PieData(org.xclcharts.chart.PieData)

Example 13 with PieData

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

the class ClickPieChart01View method chartDataSet.

private void chartDataSet() {
    // 设置图表数据源
    PieData pd1 = new PieData("48", "48%", 45, Color.rgb(215, 124, 124));
    // pd1.setItemLabelRotateAngle(90);
    PieData pd2 = new PieData("15", "15%", 15, Color.rgb(253, 180, 90));
    // pd2.setItemLabelRotateAngle(90);
    PieData pd3 = new PieData("5", "5%", 5, Color.rgb(77, 83, 97));
    // pd3.setItemLabelRotateAngle(90);
    PieData pd4 = new PieData("10", "10%", 10f, Color.rgb(253, 180, 90));
    // pd4.setItemLabelRotateAngle(90); //360 * 0.10f);
    PieData pd5 = new PieData("其它", "25%", 25, Color.rgb(52, 194, 188), true);
    // pd5.setItemLabelRotateAngle(90);
    chartData.add(pd1);
    chartData.add(pd2);
    chartData.add(pd3);
    chartData.add(pd4);
    // 将此比例块突出显示
    chartData.add(pd5);
}
Also used : PieData(org.xclcharts.chart.PieData)

Example 14 with PieData

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

the class SpinnerPieChart01View method chartDataSet.

private void chartDataSet() {
    // 设置图表数据源
    chartData.add(new PieData("User1", "15%", 15, Color.rgb(203, 183, 60)));
    chartData.add(new PieData("User2", "25%", 25, Color.rgb(214, 222, 207), false));
    chartData.add(new PieData("User3", "10%", 10, Color.rgb(164, 202, 81)));
    // 将此比例块突出显示
    chartData.add(new PieData("User4", "18%", 18, Color.rgb(1, 172, 241), true));
    chartData.add(new PieData("User5", "22%", 22, Color.rgb(99, 179, 150), true));
    chartData.add(new PieData("User6", "10%", 10, Color.rgb(52, 97, 138)));
}
Also used : PieData(org.xclcharts.chart.PieData)

Example 15 with PieData

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

the class PieChart02View method triggerClick.

// 触发监听
private void triggerClick(float x, float y) {
    if (!chart.getListenItemClickStatus())
        return;
    ArcPosition record = chart.getPositionRecord(x, y);
    if (null == record)
        return;
    PieData pData = chartData.get(record.getDataID());
    // boolean isInvaldate = true;
    for (int i = 0; i < chartData.size(); i++) {
        PieData cData = chartData.get(i);
        if (i == record.getDataID()) {
            if (cData.getSelected()) {
                // isInvaldate = false;
                break;
            } else {
                cData.setSelected(true);
            }
        } else
            cData.setSelected(false);
    }
    // 显示选中框
    chart.showFocusArc(record, pData.getSelected());
    chart.getFocusPaint().setStyle(Style.STROKE);
    chart.getFocusPaint().setStrokeWidth(5);
    chart.getFocusPaint().setColor(Color.GREEN);
    chart.getFocusPaint().setAlpha(100);
    // 在点击处显示tooltip
    mPaintToolTip.setColor(Color.RED);
    chart.getToolTip().setCurrentXY(x, y);
    chart.getToolTip().addToolTip(" key:" + pData.getKey() + " Label:" + pData.getLabel(), mPaintToolTip);
    this.refreshChart();
}
Also used : ArcPosition(org.xclcharts.event.click.ArcPosition) PieData(org.xclcharts.chart.PieData) Paint(android.graphics.Paint)

Aggregations

PieData (org.xclcharts.chart.PieData)23 ArcPosition (org.xclcharts.event.click.ArcPosition)5 Paint (android.graphics.Paint)3 PointF (android.graphics.PointF)1 ArrayList (java.util.ArrayList)1 PlotDot (org.xclcharts.renderer.line.PlotDot)1 PlotLegend (org.xclcharts.renderer.plot.PlotLegend)1