Search in sources :

Example 1 with PieChart

use of com.extjs.gxt.charts.client.model.charts.PieChart in project activityinfo by bedatadriven.

the class ChartOFCView method addPieChart.

private void addPieChart(ChartModel cm, List<PivotTableData.Axis> categories, List<PivotTableData.Axis> series) {
    PieChart pieChart = new PieChart();
    List<PieChart.Slice> slices = Lists.newArrayList();
    List<String> colors = Lists.newArrayList();
    int colorIndex = 0;
    for (PivotTableData.Axis category : categories) {
        PivotTableData.Cell cell = category.getCell(series.get(0));
        if (cell != null) {
            PieChart.Slice slice = new PieChart.Slice(cell.getValue(), category.flattenLabel());
            slices.add(slice);
            colors.add(Theme.getAccent(colorIndex++));
        }
    }
    Collections.sort(slices, new Comparator<PieChart.Slice>() {

        @Override
        public int compare(Slice o1, Slice o2) {
            double d1 = o1.getValue().doubleValue();
            double d2 = o2.getValue().doubleValue();
            return Double.compare(d2, d1);
        }
    });
    pieChart.addSlices(slices);
    pieChart.setColours(colors);
    cm.addChartConfig(pieChart);
}
Also used : PieChart(com.extjs.gxt.charts.client.model.charts.PieChart) PivotTableData(org.activityinfo.legacy.shared.reports.content.PivotTableData) Slice(com.extjs.gxt.charts.client.model.charts.PieChart.Slice) Slice(com.extjs.gxt.charts.client.model.charts.PieChart.Slice)

Aggregations

PieChart (com.extjs.gxt.charts.client.model.charts.PieChart)1 Slice (com.extjs.gxt.charts.client.model.charts.PieChart.Slice)1 PivotTableData (org.activityinfo.legacy.shared.reports.content.PivotTableData)1