diff options
| author | Fabien Pinckaers <fp@tinyerp.com> | 2012-05-07 17:55:01 +0200 |
|---|---|---|
| committer | Fabien Pinckaers <fp@tinyerp.com> | 2012-05-07 17:55:01 +0200 |
| commit | dbaef2660ad2a94e432ff8608a257c96095a962b (patch) | |
| tree | 6236c9e0f8fccf9e7661068bfb744e0514034b16 /addons/web_graph/static/src/js/graph.js | |
| parent | 1105b571b4d6ff88ddb0a5b74668bf78f5348de6 (diff) | |
[IMP] ajax call to get data
bzr revid: fp@tinyerp.com-20120507155501-sccb3bs847zu0erv
Diffstat (limited to 'addons/web_graph/static/src/js/graph.js')
| -rw-r--r-- | addons/web_graph/static/src/js/graph.js | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/addons/web_graph/static/src/js/graph.js b/addons/web_graph/static/src/js/graph.js index 9b4f123111e..fe5e901abd8 100644 --- a/addons/web_graph/static/src/js/graph.js +++ b/addons/web_graph/static/src/js/graph.js @@ -28,6 +28,10 @@ instance.web_graph.GraphView = instance.web.View.extend({ this.legend_container; this.legend="top"; // top, inside, no + this.domain = []; + this.context = {}; + this.group_by = {}; + this.is_loaded = $.Deferred(); this.graph = null; @@ -40,12 +44,12 @@ instance.web_graph.GraphView = instance.web.View.extend({ on_loaded: function(fields_view_get) { // TODO: move to load_view and document - var width, height; + var width, height; var self = this; this.fields_view = fields_view_get; this.container = this.$element.find("#editor-render-body"); - width = this.$element.parent().width(); + width = this.$element.parent().width(); this.container.css("width", width); this.$element.css("width", width); this.container.css("height", Math.min(500, width*0.8)); @@ -111,7 +115,6 @@ instance.web_graph.GraphView = instance.web.View.extend({ } ); this._super(); - this.graph_render() }, get_format: function get_format(options) { @@ -144,6 +147,24 @@ instance.web_graph.GraphView = instance.web.View.extend({ d1 = [], d2 = [], d3 = []; + + var data; + data = this.rpc( + '/web_graph/graph/data_get', + { + domain: this.domain, + context: this.context, + group_by: this.group_by, + view_id: this.view_id, + orientation: this.orientation + }, + function(result) { + console.log(result); + } + ); + + // return data + for (i = -3; i < 3; i++) { if (this.orientation % 2) { d1.push([Math.random(), i]); @@ -271,13 +292,17 @@ instance.web_graph.GraphView = instance.web.View.extend({ // render the graph using the domain, context and group_by // calls the 'graph_data_get' python controller to process all data + // TODO: check is group_by should better be in the context do_search: function(domain, context, group_by) { - var self = this; - return $.when(this.is_loaded).pipe(function() { - // todo: find the right syntax to perform an Ajax call - // return self.rpc.graph_get_data(self.view_id, domain, context, group_by).then($.proxy(self, 'schedule_chart')); - $.proxy(self, "graph_render"); - }); + this.domain = domain; + this.context = context; + this.group_by = group_by; + + this.graph_render(); + //return $.when(this.is_loaded).pipe(function() { + // // todo: find the right syntax to perform an Ajax call + // // return self.rpc.graph_get_data(self.view_id, domain, context, group_by).then($.proxy(self, 'schedule_chart')); + //}); }, do_show: function() { |
