From af2c4a191aa8cfa34435ba67f09e2a1bea86afb0 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Tue, 18 Mar 2014 21:32:01 -0400
Subject: [PATCH] Documentation
---
src/main/java/com/gitblit/wicket/charting/GooglePieChart.java | 28 ++++++++++------------------
1 files changed, 10 insertions(+), 18 deletions(-)
diff --git a/src/main/java/com/gitblit/wicket/charting/GooglePieChart.java b/src/main/java/com/gitblit/wicket/charting/GooglePieChart.java
index a9b4667..7119166 100644
--- a/src/main/java/com/gitblit/wicket/charting/GooglePieChart.java
+++ b/src/main/java/com/gitblit/wicket/charting/GooglePieChart.java
@@ -24,9 +24,9 @@
/**
* Builds an interactive pie chart using the Visualization API.
- *
+ *
* @author James Moger
- *
+ *
*/
public class GooglePieChart extends GoogleChart {
@@ -47,23 +47,15 @@
Collections.sort(values);
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) {
+ list.addAll(values.subList(0, maxSlices));
+ } else {
+ list.addAll(values);
}
- 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);
- }
-
+
StringBuilder colors = new StringBuilder("colors:[");
for (int i = 0; i < list.size(); i++) {
ChartValue value = list.get(i);
@@ -73,7 +65,7 @@
if (i < values.size() - 1) {
colors.append(',');
}
- line(sb, MessageFormat.format("{0}.setValue({1,number,0}, 0, ''{2}'');", dName, i,
+ line(sb, MessageFormat.format("{0}.setValue({1,number,0}, 0, \"{2}\");", dName, i,
value.name));
line(sb, MessageFormat.format("{0}.setValue({1,number,0}, 1, {2,number,0.0});", dName,
i, value.value));
--
Gitblit v1.9.1