diff options
| author | Christophe Simonis <chs@openerp.com> | 2011-11-08 17:36:44 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@openerp.com> | 2011-11-08 17:36:44 +0100 |
| commit | 2ea47dc3b2aac73256f361c8ca65de7d8cb40e2c (patch) | |
| tree | 48ba730f8783b0dcfae4d1230c9f4aeea7a9ff1a /addons/web_graph/static/src | |
| parent | 1b7125432843d0db93628b04e56065e77d7d14ee (diff) | |
| parent | 61823d98e9177aefa0e6aecd8750ce2bcb192e9a (diff) | |
merge upstream
bzr revid: chs@openerp.com-20111108163644-8mlg48lua376lzgg
Diffstat (limited to 'addons/web_graph/static/src')
| -rw-r--r-- | addons/web_graph/static/src/js/graph.js | 178 |
1 files changed, 104 insertions, 74 deletions
diff --git a/addons/web_graph/static/src/js/graph.js b/addons/web_graph/static/src/js/graph.js index bac147b1a91..04e9d77f5d0 100644 --- a/addons/web_graph/static/src/js/graph.js +++ b/addons/web_graph/static/src/js/graph.js @@ -13,7 +13,6 @@ var COLOR_PALETTE = [ '#cc0000', '#d400a8']; var QWeb = openerp.web.qweb; -QWeb.add_template('/web_graph/static/src/xml/web_graph.xml'); openerp.web.views.add('graph', 'openerp.web_graph.GraphView'); openerp.web_graph.GraphView = openerp.web.View.extend({ @@ -29,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(); @@ -256,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; |
