From 57ea8384a72a52b3fed072b891c8b9437888dd43 Mon Sep 17 00:00:00 2001 From: "Kunal Chavda (OpenERP)" Date: Mon, 11 Apr 2011 16:09:25 +0530 Subject: [PATCH] [IMP]Initially show stackedbar chart with static data. bzr revid: kch@tinyerp.com-20110411103925-6o0bgwp71njh33bs --- addons/base/static/src/xml/base.xml | 6 +- addons/base_graph/static/src/graph.js | 118 ++++++++++++++++++++++---- 2 files changed, 106 insertions(+), 18 deletions(-) diff --git a/addons/base/static/src/xml/base.xml b/addons/base/static/src/xml/base.xml index 211d39ad3a7..06930985429 100644 --- a/addons/base/static/src/xml/base.xml +++ b/addons/base/static/src/xml/base.xml @@ -210,7 +210,11 @@ - + +
+
+
+
diff --git a/addons/base_graph/static/src/graph.js b/addons/base_graph/static/src/graph.js index 30315b37aa8..d7d8b1c7ac9 100644 --- a/addons/base_graph/static/src/graph.js +++ b/addons/base_graph/static/src/graph.js @@ -49,23 +49,107 @@ openerp.base.GraphView = openerp.base.Controller.extend({ this.$element.html(QWeb.render("GraphView", {"view": this, "fields_view": this.fields_view})); }, create_graph: function(res) { - if (this.graph_type == "bar"){ - var barChart1 = new dhtmlXChart({ - view:"bar", - container:"chart1", - value:"#"+this.fields['total']+"#", - color:"#9abe00", - width:40, - tooltip: "#"+this.fields['id']+"#", - xAxis:{ - template:"#"+this.fields['id']+"#" - }, - yAxis:{ - title: "Total" - } - }); - barChart1.parse(res, "json"); - } + //if (this.graph_type == "bar"){ + var barChart = new dhtmlXChart({ + view:"bar", + container:"barchart", + value:"#"+this.fields['total']+"#", + color:"#9abe00", + width:40, + tooltip: "#"+this.fields['id']+"#", + xAxis:{ + template:"#"+this.fields['id']+"#" + }, + yAxis:{ + title: "Total" + } + }); + barChart.parse(res, "json"); + //} + var pieChart = new dhtmlXChart({ + view: "pie", + container: "piechart", + value: "#"+this.fields['total']+"#", + label: "#"+this.fields['id']+"#", + pieInnerText: "#"+this.fields['total']+"#", + gradient: true, + radius: 90, + x: 280, + y: 150 + }); + pieChart.parse(res, "json"); + + /*static data for stackedbar chart*/ + var data = [{ + total: "2.0", + total1: "0.0", + stage: "Lost" + }, { + total: "1.0", + total1: "2.0", + stage: "Negotiation" + }, { + total: "4.0", + total1: "2.0", + stage: "New" + }, { + total: "3.0", + total1: "0.0", + stage: "Proposition" + }, { + total: "1.0", + total1: "1.0", + stage: "Qualification" + }, { + total: "1.0", + total1: "0.0", + stage: "Won" + }]; + + var stackedChart = new dhtmlXChart({ + view: "stackedBar", + container: "stackedchart", + value: "#total#", + label: "#total#", + width: 60, + tooltip: { + template: "#total#" + }, + xAxis: { + template: "#stage#" + }, + yAxis: { + title: "User" + }, + gradient: "3d", + color: "#66cc33", + legend: { + values: [{ + text: "Administrator", + color: "#66cc33" + }, { + text: "Demo User", + color: "#ff9933" + }], + valign: "top", + align: "right", + width: 120, + layout: "y", + marker: { + width: 15, + type: "round" + } + } + }); + stackedChart.addSeries({ + value: "#total1#", + color: "#ff9933", + label: "#total1#", + tooltip: { + template: "#total1#" + } + }); + stackedChart.parse(data, "json"); },