James Moger
2013-06-12 67439a1521ed82aa19c38c2c3cc54e8d6f74afe5
Only show top 10 slices of the pie chart
1 files modified
16 ■■■■ changed files
src/main/java/com/gitblit/wicket/charting/GooglePieChart.java 16 ●●●● patch | view | raw | blame | history
src/main/java/com/gitblit/wicket/charting/GooglePieChart.java
@@ -49,19 +49,11 @@
        List<ChartValue> list = new ArrayList<ChartValue>();
        
        int maxSlices = 10;
        int maxCount = Math.min(maxSlices - 1,  values.size());
        
        for (int i = 0; i < maxCount; i++) {
            ChartValue value = values.get(i);
            list.add(value);
        }
        if (values.size() >= maxSlices) {
            float others = 0;
            for (int i = maxSlices - 1; i < values.size(); i++) {
                others += values.get(i).value;
            }
            ChartValue other = new ChartValue("other", others);
            list.add(other);
        if (values.size() > maxSlices) {
            list.addAll(values.subList(0,  maxSlices));
        } else {
            list.addAll(values);
        }
        
        StringBuilder colors = new StringBuilder("colors:[");