From ddcd41dc33176f2df07a653ac82fcda4bec04c65 Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Mon, 7 May 2012 12:34:07 +0200 Subject: [PATCH] [IMP] loading but crashing bzr revid: fp@tinyerp.com-20120507103407-h39dmn0u7bekqozd --- addons/web_graph/__openerp__.py | 31 +++++++- addons/web_graph/static/lib/flotr2/Makefile | 5 ++ addons/web_graph/static/src/js/graph.js | 85 ++++++++++----------- 3 files changed, 77 insertions(+), 44 deletions(-) diff --git a/addons/web_graph/__openerp__.py b/addons/web_graph/__openerp__.py index 72a60ef240f..5cd5765aedf 100644 --- a/addons/web_graph/__openerp__.py +++ b/addons/web_graph/__openerp__.py @@ -13,7 +13,36 @@ "version": "3.0", "depends": ['web'], "js": [ - "static/lib/flotr2/flotr2.js", + "static/lib/flotr2/lib/bean.js", + "static/lib/flotr2/js/Flotr.js", + "static/lib/flotr2/js/DefaultOptions.js", + "static/lib/flotr2/js/Color.js", + "static/lib/flotr2/js/Date.js", + "static/lib/flotr2/js/DOM.js", + "static/lib/flotr2/js/EventAdapter.js", + "static/lib/flotr2/js/Text.js", + "static/lib/flotr2/js/Graph.js", + "static/lib/flotr2/js/Axis.js", + "static/lib/flotr2/js/Series.js", + "static/lib/flotr2/js/types/lines.js", + "static/lib/flotr2/js/types/bars.js", + "static/lib/flotr2/js/types/bubbles.js", + "static/lib/flotr2/js/types/candles.js", + "static/lib/flotr2/js/types/gantt.js", + "static/lib/flotr2/js/types/markers.js", + "static/lib/flotr2/js/types/pie.js", + "static/lib/flotr2/js/types/points.js", + "static/lib/flotr2/js/types/radar.js", + "static/lib/flotr2/js/types/timeline.js", + "static/lib/flotr2/js/plugins/crosshair.js", + "static/lib/flotr2/js/plugins/download.js", + "static/lib/flotr2/js/plugins/grid.js", + "static/lib/flotr2/js/plugins/hit.js", + "static/lib/flotr2/js/plugins/selection.js", + "static/lib/flotr2/js/plugins/labels.js", + "static/lib/flotr2/js/plugins/legend.js", + "static/lib/flotr2/js/plugins/spreadsheet.js", + "static/lib/flotr2/js/plugins/titles.js", "static/src/js/graph.js" ], "css": [ diff --git a/addons/web_graph/static/lib/flotr2/Makefile b/addons/web_graph/static/lib/flotr2/Makefile index 3fd8e8f3a64..70157b0f3fa 100644 --- a/addons/web_graph/static/lib/flotr2/Makefile +++ b/addons/web_graph/static/lib/flotr2/Makefile @@ -28,6 +28,11 @@ flotr2-basic: libraries ie cat build/lib.min.js > flotr2-basic.min.js cat build/flotr2-basic.min.js >> flotr2-basic.min.js +flotr2-standalone: ie + smoosh make/flotr2.json + cat build/flotr2.js > flotr2.js + cp build/ie.min.js flotr2.ie.min.js + flotr-examples: smoosh make/examples.json cp build/examples.min.js flotr2.examples.min.js diff --git a/addons/web_graph/static/src/js/graph.js b/addons/web_graph/static/src/js/graph.js index 0dff7ca64e5..50f58a942e2 100644 --- a/addons/web_graph/static/src/js/graph.js +++ b/addons/web_graph/static/src/js/graph.js @@ -39,54 +39,54 @@ instance.web_graph.GraphView = instance.web.View.extend({ }, on_loaded: function(fields_view_get) { + var container; this.$element.html(QWeb.render("GraphView", {})); - // Should I add this, in every $(...) call ? - container = $("#editor-render-body"); - $("#graph_bar,#graph_bar_stacked").click( - {mode: 'bar', stacked: true, legend: 'top'}, graph_render) + container = this.$element.find("#editor-render-body"); + this.$element.find("#graph_bar,#graph_bar_stacked").click( + {mode: 'bar', stacked: true, legend: 'top'}, this.graph_render) - $("#graph_bar_not_stacked").click( - {mode: 'bar', stacked: false, legend: 'top'}, graph_render) + this.$element.find("#graph_bar_not_stacked").click( + {mode: 'bar', stacked: false, legend: 'top'}, this.graph_render) - $("#graph_area,#graph_area_stacked").click( - {mode: "area", stacked: true, legend: "top"}, graph_render); + this.$element.find("#graph_area,#graph_area_stacked").click( + {mode: "area", stacked: true, legend: "top"}, this.graph_render); - $("#graph_area_not_stacked").click( - {mode: "area", stacked: false, legend: "top"}, graph_render); + this.$element.find("#graph_area_not_stacked").click( + {mode: "area", stacked: false, legend: "top"}, this.graph_render); - $("#graph_radar").click( - {orientation: 0, mode: "radar", legend: "inside"}, graph_render); + this.$element.find("#graph_radar").click( + {orientation: 0, mode: "radar", legend: "inside"}, this.graph_render); - $("#graph_pie").click( - {mode: "pie", legend: "inside"}, graph_render); + this.$element.find("#graph_pie").click( + {mode: "pie", legend: "inside"}, this.graph_render); - $("#graph_legend_top").click( - {legend: "top"}, graph_render); + this.$element.find("#graph_legend_top").click( + {legend: "top"}, this.graph_render); - $("#graph_legend_inside").click( - {legend: "inside"}, graph_render); + this.$element.find("#graph_legend_inside").click( + {legend: "inside"}, this.graph_render); - $("#graph_legend_no").click( - {legend: "no"}, graph_render); + this.$element.find("#graph_legend_no").click( + {legend: "no"}, this.graph_render); - $("#graph_line").click( - {mode: "line"}, graph_render); + this.$element.find("#graph_line").click( + {mode: "line"}, this.graph_render); - $("#graph_show_data").click( + this.$element.find("#graph_show_data").click( function() { spreadsheet = ! spreadsheet; - graph_render(); + this.graph_render(); } ); - $("#graph_switch").click( + this.$element.find("#graph_switch").click( function() { orientation = ! orientation; - graph_render(); + this.graph_render(); } ); - $("#graph_download").click( + this.$element.find("#graph_download").click( function() { var graph; if (Flotr.isIE && Flotr.isIE < 9) { @@ -97,7 +97,7 @@ instance.web_graph.GraphView = instance.web.View.extend({ } if (legend=="top") legend="inside"; forcehtml = true; - graph = graph_render(); + graph = this.graph_render(); graph.download.saveImage('png'); forcehtml = false; } @@ -113,7 +113,7 @@ instance.web_graph.GraphView = instance.web.View.extend({ if (legend=="top") { result.noColumns = 4; // todo: I guess I should add something like this.renderer ? - result.container = $("div .graph_header_legend", this)[0]; + result.container = this.$element.find("div .graph_header_legend", this)[0]; } else if (legend=="inside") { result.position = 'nw'; result.backgroundColor = '#D2E8FF'; @@ -189,7 +189,7 @@ instance.web_graph.GraphView = instance.web.View.extend({ yaxis : {showLabels: false}, }) ) - } + }, graph_radar: function (container, data) { return Flotr.draw(container, data, get_format({ @@ -203,7 +203,7 @@ instance.web_graph.GraphView = instance.web.View.extend({ } }) ) - } + }, graph_line: function (container, data) { return Flotr.draw(container, data, get_format({ @@ -219,7 +219,7 @@ instance.web_graph.GraphView = instance.web.View.extend({ labelsAngle : 45 }) ) - } + }, // Render the graph and update menu styles graph_render: function (options) { @@ -232,7 +232,7 @@ instance.web_graph.GraphView = instance.web.View.extend({ mode_options = (this.mode=='area')?{lines: {fill: true}}:{} // Render the graph - $(".graph_header_legend").children().remove() + this.$element.find(".graph_header_legend").children().remove() data = this.get_data(mode_options); graph = { radar: graph_radar, @@ -244,25 +244,24 @@ instance.web_graph.GraphView = instance.web.View.extend({ // Update styles of menus - $("a[id^='graph_']").removeClass("active"); - $("a[id='graph_"+mode+"']").addClass("active"); - $("a[id='graph_"+mode+(this.stacked?"_stacked":"_not_stacked")+"']").addClass("active"); + this.$element.find("a[id^='graph_']").removeClass("active"); + this.$element.find("a[id='graph_"+mode+"']").addClass("active"); + this.$element.find("a[id='graph_"+mode+(this.stacked?"_stacked":"_not_stacked")+"']").addClass("active"); if (this.legend=='inside') - $("a[id='graph_legend_inside']").addClass("active"); + this.$element.find("a[id='graph_legend_inside']").addClass("active"); else if (this.legend=='top') - $("a[id='graph_legend_top']").addClass("active"); + this.$element.find("a[id='graph_legend_top']").addClass("active"); else - $("a[id='graph_legend_no']").addClass("active"); + this.$element.find("a[id='graph_legend_no']").addClass("active"); if (this.spreadsheet) - $("a[id='graph_show_data']").addClass("active"); + this.$element.find("a[id='graph_show_data']").addClass("active"); return graph; - } - + }, schedule_chart: function(results) { - self.graph_render({}) + this.graph_render({}) }, // render the graph using the domain, context and group_by