Merge branch 'ticket/77' into develop
| | |
| | | |
| | | @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)); |
| | |
| | | } |
| | | sb.append("[\"" + label + "\", " + value.name + "]"); |
| | | } |
| | | |
| | | |
| | | } |
| | | else { |
| | | for (int i = 0; i < values.size(); i++) { |
| | |
| | | } |
| | | } |
| | | line(sb, "];"); |
| | | |
| | | |
| | | line(sb, MessageFormat.format("var {0} = Flotr.draw(document.getElementById(''{1}''),", dName, tagId)); |
| | | |
| | | |
| | | // Add the data |
| | | line(sb, "["); |
| | | line(sb, "{ data : [ "); |
| | |
| | | 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',"); |
| | |
| | | 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,"); |
| | |
| | | line(sb, " show: false"); |
| | | line(sb, "}"); |
| | | line(sb, "});"); |
| | | |
| | | |
| | | } |
| | | |
| | | @Override |
| | |
| | | String name = String.valueOf(date.getTime()); |
| | | super.addValue(name, value); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | |
| | | @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)); |
| | |
| | | } |
| | | sb.append("\"" + label + "\""); |
| | | } |
| | | |
| | | |
| | | } |
| | | else { |
| | | for (int i = 0; i < values.size(); i++) { |
| | |
| | | } |
| | | } |
| | | line(sb, "];"); |
| | | |
| | | |
| | | line(sb, MessageFormat.format("var {0} = Flotr.draw(document.getElementById(''{1}''),", dName, tagId)); |
| | | |
| | | |
| | | // Add the data |
| | | line(sb, "["); |
| | | line(sb, "{ data : [ "); |
| | |
| | | } |
| | | 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 : [ "); |
| | |
| | | } |
| | | 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,"); |
| | |
| | | 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,"); |
| | |
| | | line(sb, " show: false"); |
| | | line(sb, "}"); |
| | | line(sb, "});"); |
| | | |
| | | |
| | | } |
| | | |
| | | @Override |
| | |
| | | xAxisIsDate = true; |
| | | super.addValue(date, value); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | |
| | | @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++) { |
| | |
| | | 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,"); |
| | |
| | | line(sb, " outlineWidth: 0"); |
| | | line(sb, "}"); |
| | | line(sb, ", legend: {"); |
| | | if(showLegend){ |
| | | if(showLegend){ |
| | | line(sb, " show: true"); |
| | | } |
| | | else { |
| | |
| | | } |
| | | 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, "});"); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | } |