diff options
author | James Moger <james.moger@gitblit.com> | 2014-05-15 13:19:44 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2014-05-15 13:19:44 -0400 |
commit | 7b835f5a9bb54de4997ea16dc48971aa20b1bbbf (patch) | |
tree | b931056dee59860a53a4449e170c4c4e13007ab6 | |
parent | 72f7b1f1d48237f7fd078027ae74102726fd57cf (diff) | |
download | gitblit-7b835f5a9bb54de4997ea16dc48971aa20b1bbbf.tar.gz gitblit-7b835f5a9bb54de4997ea16dc48971aa20b1bbbf.zip |
Wrap flotr2 chart labels with double-quotes not single-quotes
3 files changed, 46 insertions, 45 deletions
diff --git a/src/main/java/com/gitblit/wicket/charting/Flotr2BarChart.java b/src/main/java/com/gitblit/wicket/charting/Flotr2BarChart.java index 4f07555e..f13619ae 100644 --- a/src/main/java/com/gitblit/wicket/charting/Flotr2BarChart.java +++ b/src/main/java/com/gitblit/wicket/charting/Flotr2BarChart.java @@ -40,27 +40,28 @@ public class Flotr2BarChart extends Chart { @Override protected void appendChart(StringBuilder sb) { - + String dName = "data_" + dataName; sb.append("var labels_" + dataName + " = ["); if(xAxisIsDate){ - + // Generate labels for the dates SimpleDateFormat df = new SimpleDateFormat(dateFormat); df.setTimeZone(getTimeZone()); - + // Sort the values first Collections.sort(values, new Comparator<ChartValue>() { - public int compare(ChartValue o1, ChartValue o2) { + @Override + public int compare(ChartValue o1, ChartValue o2) { long long1 = Long.parseLong(o1.name); long long2 = Long.parseLong(o2.name); return (int) (long2 - long1); } - + }); - - + + for (int i = 0; i < values.size(); i++) { ChartValue value = values.get(i); Date date = new Date(Long.parseLong(value.name)); @@ -70,7 +71,7 @@ public class Flotr2BarChart extends Chart { } sb.append("[\"" + label + "\", " + value.name + "]"); } - + } else { for (int i = 0; i < values.size(); i++) { @@ -82,9 +83,9 @@ public class Flotr2BarChart extends Chart { } } line(sb, "];"); - + line(sb, MessageFormat.format("var {0} = Flotr.draw(document.getElementById(''{1}''),", dName, tagId)); - + // Add the data line(sb, "["); line(sb, "{ data : [ "); @@ -99,22 +100,22 @@ public class Flotr2BarChart extends Chart { else { line(sb, MessageFormat.format("[{0}, {1}] ", Integer.toString(i), Float.toString(value.value))); } - + } - line(sb, MessageFormat.format(" ], label : ''{0}'', color: ''#FF9900'' '}'", valueName)); + line(sb, MessageFormat.format(" ], label : \"{0}\", color: ''#FF9900'' '}'", valueName)); line(sb, "]"); - + // Add the options line(sb, ", {"); if(title != null && title.isEmpty() == false){ - line(sb, MessageFormat.format("title : ''{0}'',", title)); + line(sb, MessageFormat.format("title : \"{0}\",", title)); } line(sb, "bars : {"); line(sb, " show : true,"); line(sb, " horizontal : false,"); line(sb, " barWidth : 1"); line(sb, "},"); - line(sb, "points: { show: false },"); + line(sb, "points: { show: false },"); line(sb, "mouse: {"); line(sb, " track: true,"); line(sb, " lineColor: '#002060',"); @@ -132,7 +133,7 @@ public class Flotr2BarChart extends Chart { line(sb, " return labels_" + dataName + "[index];"); line(sb, " return \"\";"); line(sb, " },"); - line(sb, " margin: 10"); + line(sb, " margin: 10"); line(sb, "},"); line(sb, "yaxis: {"); line(sb, " showLabels: false,"); @@ -152,7 +153,7 @@ public class Flotr2BarChart extends Chart { line(sb, " show: false"); line(sb, "}"); line(sb, "});"); - + } @Override @@ -161,7 +162,7 @@ public class Flotr2BarChart extends Chart { String name = String.valueOf(date.getTime()); super.addValue(name, value); } - - + + } diff --git a/src/main/java/com/gitblit/wicket/charting/Flotr2LineChart.java b/src/main/java/com/gitblit/wicket/charting/Flotr2LineChart.java index f795999c..1123516b 100644 --- a/src/main/java/com/gitblit/wicket/charting/Flotr2LineChart.java +++ b/src/main/java/com/gitblit/wicket/charting/Flotr2LineChart.java @@ -38,14 +38,14 @@ public class Flotr2LineChart extends Chart { @Override protected void appendChart(StringBuilder sb) { - + String dName = "data_" + dataName; sb.append("var labels_" + dataName + " = ["); if(xAxisIsDate){ // Generate labels for the dates SimpleDateFormat df = new SimpleDateFormat(dateFormat); - df.setTimeZone(getTimeZone()); - + df.setTimeZone(getTimeZone()); + for (int i = 0; i < values.size(); i++) { ChartValue value = values.get(i); Date date = new Date(Long.parseLong(value.name)); @@ -55,7 +55,7 @@ public class Flotr2LineChart extends Chart { } sb.append("\"" + label + "\""); } - + } else { for (int i = 0; i < values.size(); i++) { @@ -67,9 +67,9 @@ public class Flotr2LineChart extends Chart { } } line(sb, "];"); - + line(sb, MessageFormat.format("var {0} = Flotr.draw(document.getElementById(''{1}''),", dName, tagId)); - + // Add the data line(sb, "["); line(sb, "{ data : [ "); @@ -80,8 +80,8 @@ public class Flotr2LineChart extends Chart { } line(sb, MessageFormat.format("[{0}, {1}] ", value.name, Float.toString(value.value))); } - line(sb, MessageFormat.format(" ], label : ''{0}'', lines : '{' show : true '}', color: ''#ff9900'' '}'", valueName)); - + line(sb, MessageFormat.format(" ], label : \"{0}\", lines : '{' show : true '}', color: ''#ff9900'' '}'", valueName)); + if(highlights.size() > 0){ // get the highlights line(sb, ", { data : [ "); @@ -92,14 +92,14 @@ public class Flotr2LineChart extends Chart { } line(sb, MessageFormat.format("[{0}, {1}] ", value.name, Float.toString(value.value))); } - line(sb, MessageFormat.format(" ], label : ''{0}'', points : '{' show : true, fill: true, fillColor:''#002060'' '}', color: ''#ff9900'' '}'", valueName)); + line(sb, MessageFormat.format(" ], label : \"{0}\", points : '{' show : true, fill: true, fillColor:''#002060'' '}', color: ''#ff9900'' '}'", valueName)); } line(sb, "]"); - + // Add the options line(sb, ", {"); if(title != null && title.isEmpty() == false){ - line(sb, MessageFormat.format("title : ''{0}'',", title)); + line(sb, MessageFormat.format("title : \"{0}\",", title)); } line(sb, "mouse: {"); line(sb, " track: true,"); @@ -114,7 +114,7 @@ public class Flotr2LineChart extends Chart { line(sb, " showMinorLabels: false,"); line(sb, " autoscale: true,"); line(sb, " autoscaleMargin: 0,"); - line(sb, " margin: 10"); + line(sb, " margin: 10"); line(sb, "},"); line(sb, "yaxis: {"); line(sb, " showLabels: false,"); @@ -136,7 +136,7 @@ public class Flotr2LineChart extends Chart { line(sb, " show: false"); line(sb, "}"); line(sb, "});"); - + } @Override @@ -144,7 +144,7 @@ public class Flotr2LineChart extends Chart { xAxisIsDate = true; super.addValue(date, value); } - - + + } diff --git a/src/main/java/com/gitblit/wicket/charting/Flotr2PieChart.java b/src/main/java/com/gitblit/wicket/charting/Flotr2PieChart.java index ea04db94..f537e269 100644 --- a/src/main/java/com/gitblit/wicket/charting/Flotr2PieChart.java +++ b/src/main/java/com/gitblit/wicket/charting/Flotr2PieChart.java @@ -35,11 +35,11 @@ public class Flotr2PieChart extends Chart { @Override protected void appendChart(StringBuilder sb) { - + String dName = "data_" + dataName; line(sb, "var selected_" + dataName + " = null;"); line(sb, MessageFormat.format("var {0} = Flotr.draw(document.getElementById(''{1}''),", dName, tagId)); - + // Add the data line(sb, "["); for (int i = 0; i < values.size(); i++) { @@ -47,13 +47,13 @@ public class Flotr2PieChart extends Chart { if(i > 0){ sb.append(","); } - line(sb, MessageFormat.format("'{'data : [ [0, {0}] ], label : ''{1}'', color: ''{2}'' '}'", Float.toString(value.value), value.name, StringUtils.getColor(value.name))); + line(sb, MessageFormat.format("'{'data : [ [0, {0}] ], label : \"{1}\", color: ''{2}'' '}'", Float.toString(value.value), value.name, StringUtils.getColor(value.name))); } line(sb, "]"); - + // Add the options line(sb, ", {"); - line(sb, MessageFormat.format("title : ''{0}'',", title)); + line(sb, MessageFormat.format("title : \"{0}\",", title)); line(sb, "fontSize : 2,"); line(sb, "pie : {"); line(sb, " show : true,"); @@ -90,7 +90,7 @@ public class Flotr2PieChart extends Chart { line(sb, " outlineWidth: 0"); line(sb, "}"); line(sb, ", legend: {"); - if(showLegend){ + if(showLegend){ line(sb, " show: true"); } else { @@ -98,15 +98,15 @@ public class Flotr2PieChart extends Chart { } line(sb, "}"); line(sb, "});"); - + if(clickUrl != null && clickUrl.isEmpty() == false){ line(sb, MessageFormat.format("Flotr.EventAdapter.observe(document.getElementById(''{0}''), ''flotr:click'', function (mouse, a, b, c) '{'", tagId)); line(sb, " window.location.href = \"" + clickUrl + "\" + selected_" + dataName + ";"); - line(sb, "});"); + line(sb, "});"); } - - - + + + } } |