| | |
| | | package com.gitblit.wicket.charting;
|
| | |
|
| | | import java.text.MessageFormat;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Collections;
|
| | | import java.util.List;
|
| | |
|
| | | import com.gitblit.utils.StringUtils;
|
| | |
|
| | |
| | | line(sb, MessageFormat.format("{0}.addRows({1,number,0});", dName, values.size()));
|
| | |
|
| | | Collections.sort(values);
|
| | |
|
| | | List<ChartValue> list = new ArrayList<ChartValue>();
|
| | | |
| | | int maxSlices = 10;
|
| | | |
| | | if (values.size() > maxSlices) {
|
| | | list.addAll(values.subList(0, maxSlices));
|
| | | } else {
|
| | | list.addAll(values);
|
| | | }
|
| | | |
| | | StringBuilder colors = new StringBuilder("colors:[");
|
| | | for (int i = 0; i < values.size(); i++) {
|
| | | ChartValue value = values.get(i);
|
| | | for (int i = 0; i < list.size(); i++) {
|
| | | ChartValue value = list.get(i);
|
| | | colors.append('\'');
|
| | | colors.append(StringUtils.getColor(value.name));
|
| | | colors.append('\'');
|
| | |
| | | cName, tagId));
|
| | | line(sb,
|
| | | MessageFormat
|
| | | .format("{0}.draw({1}, '{'width: {2,number,0}, height: {3,number,0}, chartArea:'{'left:20,top:20'}', title: ''{4}'', {5} '}');",
|
| | | cName, dName, width, height, title, colors.toString()));
|
| | | .format("{0}.draw({1}, '{' title: ''{4}'', {5}, legend: '{' position:''{6}'' '}' '}');",
|
| | | cName, dName, width, height, title, colors.toString(), showLegend ? "right" : "none"));
|
| | | line(sb, "");
|
| | | }
|
| | | } |