]> source.dussan.org Git - gitblit.git/commitdiff
Only show top 10 slices of the pie chart
authorJames Moger <james.moger@gitblit.com>
Wed, 12 Jun 2013 21:22:03 +0000 (17:22 -0400)
committerJames Moger <james.moger@gitblit.com>
Wed, 12 Jun 2013 21:22:03 +0000 (17:22 -0400)
src/main/java/com/gitblit/wicket/charting/GooglePieChart.java

index a9b46670e6d41b1b208590c141ced5293a9981aa..1f5ae7066d8e1747d141c9b9ea75cf9fb38d9840 100644 (file)
@@ -49,19 +49,11 @@ public class GooglePieChart extends GoogleChart {
                List<ChartValue> list = new ArrayList<ChartValue>();\r
                \r
                int maxSlices = 10;\r
-               int maxCount = Math.min(maxSlices - 1,  values.size());\r
                \r
-               for (int i = 0; i < maxCount; i++) {\r
-                       ChartValue value = values.get(i);\r
-                       list.add(value);\r
-               }\r
-               if (values.size() >= maxSlices) {\r
-                       float others = 0;\r
-                       for (int i = maxSlices - 1; i < values.size(); i++) {\r
-                               others += values.get(i).value;  \r
-                       }\r
-                       ChartValue other = new ChartValue("other", others);\r
-                       list.add(other);\r
+               if (values.size() > maxSlices) {\r
+                       list.addAll(values.subList(0,  maxSlices));\r
+               } else {\r
+                       list.addAll(values);\r
                }\r
                \r
                StringBuilder colors = new StringBuilder("colors:[");\r