James Moger
2014-05-15 f612b5cbaf719e05ad0fcbdd46553cd9345bc646
Merged #77 "A single quote in a chart label generates invalid JavaScript"
3 files modified
15 ■■■■ changed files
src/main/java/com/gitblit/wicket/charting/Flotr2BarChart.java 5 ●●●●● patch | view | raw | blame | history
src/main/java/com/gitblit/wicket/charting/Flotr2LineChart.java 6 ●●●● patch | view | raw | blame | history
src/main/java/com/gitblit/wicket/charting/Flotr2PieChart.java 4 ●●●● patch | view | raw | blame | history
src/main/java/com/gitblit/wicket/charting/Flotr2BarChart.java
@@ -52,6 +52,7 @@
            // Sort the values first
            Collections.sort(values, new Comparator<ChartValue>() {
                @Override
                public int compare(ChartValue o1, ChartValue o2) {
                    long long1 = Long.parseLong(o1.name);
                    long long2 = Long.parseLong(o2.name);
@@ -101,13 +102,13 @@
            }
            
        }
        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,");
src/main/java/com/gitblit/wicket/charting/Flotr2LineChart.java
@@ -80,7 +80,7 @@
            }
            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
@@ -92,14 +92,14 @@
                }
                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,");
src/main/java/com/gitblit/wicket/charting/Flotr2PieChart.java
@@ -47,13 +47,13 @@
            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,");