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