diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/dashboard/GlobalProgressChart.java b/libreplan-webapp/src/main/java/org/libreplan/web/dashboard/GlobalProgressChart.java index ae811e0ff..1f022d8df 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/dashboard/GlobalProgressChart.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/dashboard/GlobalProgressChart.java @@ -93,13 +93,14 @@ public class GlobalProgressChart { private String jsonify(Collection list) { Collection result = new ArrayList(); for (Object each : list) { - if (each.getClass() == String.class) { - result.add(String.format("\"%s\"", each.toString())); - } else { - result.add(String.format("%s", each.toString())); - } + result.add(jsonify(each)); } - return String.format("'[%s]'", StringUtils.join(result, ',')); + return String.format("[%s]", StringUtils.join(result, ',')); + } + + private String jsonify(Object value) { + return (value.getClass().equals(String.class)) ? String.format("\"%s\"", + value.toString()) : String.format("%s", value.toString()); } public String getSeries() { @@ -116,9 +117,13 @@ public class GlobalProgressChart { } public void render() { - String command = String.format( - "global_progress.render(%s, %s, %s);", getPercentages(), + String params = String.format( + "'{\"title\": %s, \"label\": %s, \"ticks\": %s, \"series\": %s}'", + jsonify(_("Project progress percentage")), + jsonify(_("Progress percentage per progress type")), getTicks(), getSeries()); + String command = String.format("global_progress.render(%s, %s);", + getPercentages(), params); Clients.evalJavaScript(command); } diff --git a/libreplan-webapp/src/main/webapp/dashboard/_globalProgress.zul b/libreplan-webapp/src/main/webapp/dashboard/_globalProgress.zul index 7b44bb721..0590c67f4 100644 --- a/libreplan-webapp/src/main/webapp/dashboard/_globalProgress.zul +++ b/libreplan-webapp/src/main/webapp/dashboard/_globalProgress.zul @@ -56,12 +56,18 @@ location: 'e', placement: 'outside', }, - render: function(data, ticks, series) { - if (ticks !== undefined) { - this.axes.yaxis.ticks = jQuery.parseJSON(ticks); + render: function(data, params) { + if (params['title'] !== undefined) { + this.title = params['title']; } - if (series !== undefined) { - this.series = jQuery.parseJSON(series); + if (params['label'] !== undefined) { + this.axes.xaxis.label = params['label']; + } + if (params['ticks'] !== undefined) { + this.axes.yaxis.ticks = params['ticks']; + } + if (params['series'] !== undefined) { + this.series = params['series']; } data = jQuery.parseJSON(data); this.plot = $.jqplot(this.id, data, this);