diff options
| author | Christophe Simonis <chs@openerp.com> | 2011-11-08 16:45:41 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@openerp.com> | 2011-11-08 16:45:41 +0100 |
| commit | 6e735ccbbee81d6be01f7c965e3248270aedc3cc (patch) | |
| tree | ae494b4af038982e508a30da2afccd894ebb52d1 /addons/web_graph/static/src/js | |
| parent | 555bb5073e8e1ce1dea7310eb5ff40e4086428b2 (diff) | |
| parent | 91f050054feb176ac4a648c69686c59d254273b8 (diff) | |
merge upstream
bzr revid: chs@openerp.com-20111103111333-93bu8xdgs30ry5ig
bzr revid: chs@openerp.com-20111108154541-dsz5sjnf7xwihg06
Diffstat (limited to 'addons/web_graph/static/src/js')
| -rw-r--r-- | addons/web_graph/static/src/js/graph.js | 177 |
1 files changed, 104 insertions, 73 deletions
diff --git a/addons/web_graph/static/src/js/graph.js b/addons/web_graph/static/src/js/graph.js index 91aaf8bdb9c..04e9d77f5d0 100644 --- a/addons/web_graph/static/src/js/graph.js +++ b/addons/web_graph/static/src/js/graph.js @@ -28,6 +28,14 @@ openerp.web_graph.GraphView = openerp.web.View.extend({ this.columns = []; this.group_field = null; this.is_loaded = $.Deferred(); + + this.renderer = null; + }, + stop: function () { + if (this.renderer) { + clearTimeout(this.renderer); + } + this._super(); }, do_show: function () { this.$element.show(); @@ -255,90 +263,113 @@ openerp.web_graph.GraphView = openerp.web.View.extend({ x_axis = abscissa_description; y_axis = ordinate_description; } - - var bar_chart = new dhtmlXChart({ - view: view_chart, - container: this.element_id+"-barchart", - value:"#"+group_list[0].group+"#", - gradient: "3d", - border: false, - width: 1024, - tooltip:{ - template: _.sprintf("#%s#, %s=#%s#", - this.abscissa, group_list[0].text, group_list[0].group) - }, - radius: 0, - color:group_list[0].color, - origin:0, - xAxis: x_axis, - yAxis: y_axis, - padding: { - left: 75 - }, - legend: { - values: group_list, - align:"left", - valign:"top", - layout: "x", - marker: { - type:"round", - width:12 - } + + var renderer = function () { + if (self.$element.is(':hidden')) { + self.renderer = setTimeout(renderer, 100); + return; } - }); - for (var m = 1; m<group_list.length;m++){ - var column = group_list[m]; - if (column.group === this.group_field) { continue; } - bar_chart.addSeries({ - value: "#"+column.group+"#", + self.renderer = null; + var bar_chart = new dhtmlXChart({ + view: view_chart, + container: self.element_id+"-barchart", + value:"#"+group_list[0].group+"#", + gradient: "3d", + border: false, + width: 1024, tooltip:{ template: _.sprintf("#%s#, %s=#%s#", - this.abscissa, column.text, column.group) + self.abscissa, group_list[0].text, group_list[0].group) + }, + radius: 0, + color:group_list[0].color, + origin:0, + xAxis: x_axis, + yAxis: y_axis, + padding: { + left: 75 }, - color: column.color + legend: { + values: group_list, + align:"left", + valign:"top", + layout: "x", + marker: { + type:"round", + width:12 + } + } + }); + for (var m = 1; m<group_list.length;m++){ + var column = group_list[m]; + if (column.group === self.group_field) { continue; } + bar_chart.addSeries({ + value: "#"+column.group+"#", + tooltip:{ + template: _.sprintf("#%s#, %s=#%s#", + self.abscissa, column.text, column.group) + }, + color: column.color + }); + } + bar_chart.parse(results, "json"); + self.$element.find("#"+self.element_id+"-barchart").height( + self.$element.find("#"+self.element_id+"-barchart").height()+50); + bar_chart.attachEvent("onItemClick", function(id) { + self.open_list_view(bar_chart.get(id)); }); + }; + if (this.renderer) { + clearTimeout(this.renderer); } - bar_chart.parse(results, "json"); - jQuery("#"+this.element_id+"-barchart").height(jQuery("#"+this.element_id+"-barchart").height()+50); - bar_chart.attachEvent("onItemClick", function(id) { - self.open_list_view(bar_chart.get(id)); - }); + this.renderer = setTimeout(renderer, 0); }, schedule_pie: function(result) { var self = this; - var chart = new dhtmlXChart({ - view:"pie3D", - container:self.element_id+"-piechart", - value:"#"+self.ordinate+"#", - pieInnerText:function(obj) { - var sum = chart.sum("#"+self.ordinate+"#"); - var val = obj[self.ordinate] / sum * 100 ; - return val.toFixed(1) + "%"; - }, - tooltip:{ - template:"#"+self.abscissa+"#"+"="+"#"+self.ordinate+"#" - }, - gradient:"3d", - height: 20, - radius: 200, - legend: { - width: 300, - align:"left", - valign:"top", - layout: "x", - marker:{ - type:"round", - width:12 + var renderer = function () { + if (self.$element.is(':hidden')) { + self.renderer = setTimeout(renderer, 100); + return; + } + self.renderer = null; + var chart = new dhtmlXChart({ + view:"pie3D", + container:self.element_id+"-piechart", + value:"#"+self.ordinate+"#", + pieInnerText:function(obj) { + var sum = chart.sum("#"+self.ordinate+"#"); + var val = obj[self.ordinate] / sum * 100 ; + return val.toFixed(1) + "%"; }, - template:function(obj){ - return obj[self.abscissa] || 'Undefined'; + tooltip:{ + template:"#"+self.abscissa+"#"+"="+"#"+self.ordinate+"#" + }, + gradient:"3d", + height: 20, + radius: 200, + legend: { + width: 300, + align:"left", + valign:"top", + layout: "x", + marker:{ + type:"round", + width:12 + }, + template:function(obj){ + return obj[self.abscissa] || 'Undefined'; + } } - } - }); - chart.parse(result,"json"); - chart.attachEvent("onItemClick", function(id) { - self.open_list_view(chart.get(id)); - }); + }); + chart.parse(result,"json"); + chart.attachEvent("onItemClick", function(id) { + self.open_list_view(chart.get(id)); + }); + }; + if (this.renderer) { + clearTimeout(this.renderer); + } + this.renderer = setTimeout(renderer, 0); }, open_list_view : function (id){ var self = this; |
