[IMP]implement code for there is no data than show axis and pass element_id instead of view_id.
bzr revid: kch@tinyerp.com-20110620121525-kq2rw54ouu3fo8da
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
/*
|
||||
Copyright DHTMLX LTD. http://www.dhtmlx.com
|
||||
You allowed to use this component or parts of it under GPL terms
|
||||
To use it on other terms or get Professional edition of the component please contact us at sales@dhtmlx.com
|
||||
*/
|
||||
/*
|
||||
Copyright DHTMLX LTD. http://www.dhtmlx.com
|
||||
You allowed to use this component or parts of it under GPL terms
|
||||
To use it on other terms or get Professional edition of the component please contact us at sales@dhtmlx.com
|
||||
*/
|
||||
.dhx_tooltip{display:none;position:absolute;font-family:Tahoma;font-size:8pt;z-index:10000;background-color:white;padding:2px 2px 2px 2px;border:1px solid #A4BED4;}
|
||||
.dhx_chart{position:relative;font-family:Verdana;font-size:13px;color:#000;overflow:hidden;}
|
||||
.dhx_canvas_text{position:absolute;text-align:center;white-space:nowrap;}
|
||||
.dhx_canvas_text{position:absolute;text-align:center;}
|
||||
.dhx_map_img{width:100%;height:100%;position:absolute;top:0;left:0;border:0;filter:alpha(opacity=0);}
|
||||
.dhx_axis_item_y{position:absolute;height:10px;line-height:10px;text-align:right;}
|
||||
.dhx_axis_title_y{text-align:center;font-family:Verdana;-webkit-transform:rotate(-90deg);-moz-transform:rotate(-90deg);filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=3);-o-transform:rotate(-90deg);padding-left:3px;}
|
||||
.dhx_axis_item_x{text-align:center;font-size:8pt;-webkit-transform:rotate(-60deg);-moz-transform:rotate(-60deg);filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=2);-o-transform:rotate(-60deg);padding-left:3px;}
|
||||
.dhx_axis_title_x{text-align:center;}
|
||||
.dhx_axis_item_x{text-align:right;margin-top:30px;margin-left:-14px;font-size:8pt;-webkit-transform:rotate(-60deg);-moz-transform:rotate(-60deg);filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=2);-o-transform:rotate(-60deg);padding-left:3px;}
|
||||
.dhx_axis_title_x{text-align:center;margin-top:50px;}
|
||||
.dhx_chart_legend{position:absolute;}
|
||||
.dhx_chart_legend_item{height:18px;line-height:18px;padding:2px;}
|
||||
.dhx_chart_legend_item{height:18px;line-height:18px;padding:2px;}
|
||||
@@ -46,6 +46,7 @@ openerp.base_graph.GraphView = openerp.base.Controller.extend({
|
||||
this.operator = [];
|
||||
this.group_field = '';
|
||||
this.orientation = this.fields_view.arch.attrs.orientation || '';
|
||||
this.elem_id = this.$element[0]['id'];
|
||||
|
||||
_.each(this.fields_view.arch.children, function (field) {
|
||||
if (field.attrs.operator) {
|
||||
@@ -81,19 +82,17 @@ openerp.base_graph.GraphView = openerp.base.Controller.extend({
|
||||
}else{
|
||||
this.dataset.read_ids(
|
||||
this.dataset.ids,
|
||||
{},
|
||||
function(res) {
|
||||
{}, function(res) {
|
||||
self.schedule_chart(res);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
schedule_chart: function(results) {
|
||||
this.$element.html(QWeb.render("GraphView", {"fields_view": this.fields_view, "chart": this.chart,'view_id': this.view_id}));
|
||||
if (!results.length) {
|
||||
this.$element.html(QWeb.render("GraphView", {"fields_view": this.fields_view, "chart": this.chart,'elem_id': this.elem_id}));
|
||||
/*if (!results.length) {
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
_.each(results, function (result) {
|
||||
_.each(result, function (field_value, field_name) {
|
||||
if (typeof field_value == 'object') {
|
||||
@@ -169,11 +168,16 @@ openerp.base_graph.GraphView = openerp.base.Controller.extend({
|
||||
}
|
||||
}, this);
|
||||
|
||||
if (group_list.length <=1){
|
||||
group_list = [];
|
||||
group_list.push(newkey = "val");
|
||||
}
|
||||
|
||||
var abscissa_data = {};
|
||||
_.each(results, function (result) {
|
||||
var label = result[self.chart_info_fields],
|
||||
section = {};
|
||||
if (self.group_field && (self.operator.length <= 1)){
|
||||
if (self.group_field && (group_list.length > 1) && (self.operator.length <= 1)){
|
||||
newkey = result[self.group_field].split(' ').join('_');
|
||||
}else{
|
||||
newkey = "val";
|
||||
@@ -196,7 +200,6 @@ openerp.base_graph.GraphView = openerp.base.Controller.extend({
|
||||
//for legend color
|
||||
var grp_color = _.map(group_list, function (group_legend, index) {
|
||||
var legend = {color: COLOR_PALETTE[index]};
|
||||
|
||||
if (group_legend == "val"){
|
||||
legend['text'] = self.fields[self.operator_field]['string']
|
||||
}else if(group_legend == "val1"){
|
||||
@@ -208,13 +211,54 @@ openerp.base_graph.GraphView = openerp.base.Controller.extend({
|
||||
});
|
||||
|
||||
//for axis's value and title
|
||||
var max_min = [];
|
||||
var max = 0;
|
||||
var min = 0;
|
||||
var step = 0;
|
||||
var stack_data = 0;
|
||||
var minimum = 0;
|
||||
|
||||
if(! _.isEmpty(abscissa_data)){
|
||||
_.each(abscissa_data, function (abscissa_datas) {
|
||||
if (group_list.length <= 1){
|
||||
max_min.push(abscissa_datas[group_list]);
|
||||
}else{
|
||||
stack_data = (abscissa_datas[group_list[0]]) + (abscissa_datas[group_list[1]]);
|
||||
max_min.push(stack_data);
|
||||
}
|
||||
});
|
||||
max = Math.max.apply(Math,max_min);
|
||||
minimum = Math.min.apply(Math,max_min);
|
||||
if (minimum < 0){
|
||||
min = minimum;
|
||||
}
|
||||
if (max != 0){
|
||||
if (max < 0){
|
||||
max = max - (10 + max % 10)
|
||||
}else{
|
||||
max = max + (10 - (max % 10))
|
||||
}
|
||||
step = Math.round(max/10);
|
||||
}else{
|
||||
max = 9;
|
||||
step = 1;
|
||||
}
|
||||
}else{
|
||||
max = 9;
|
||||
step=1;
|
||||
}
|
||||
|
||||
var abscissa_description = {
|
||||
template: self.chart_info_fields,
|
||||
title: "<b>"+self.x_title+"</b>"
|
||||
};
|
||||
|
||||
var ordinate_description = {
|
||||
lines: true,
|
||||
title: "<b>"+self.y_title+"</b>"
|
||||
title: "<b>"+self.y_title+"</b>",
|
||||
start: min,
|
||||
step: step,
|
||||
end: max
|
||||
};
|
||||
|
||||
var x_axis, y_axis;
|
||||
@@ -228,7 +272,7 @@ openerp.base_graph.GraphView = openerp.base.Controller.extend({
|
||||
|
||||
var bar_chart = new dhtmlxchartChart({
|
||||
view: view_chart,
|
||||
container: self.view_id+"-barchart",
|
||||
container: self.elem_id+"-barchart",
|
||||
value:"#"+group_list[0]+"#",
|
||||
gradient: "3d",
|
||||
border: false,
|
||||
@@ -260,7 +304,10 @@ openerp.base_graph.GraphView = openerp.base.Controller.extend({
|
||||
}
|
||||
},
|
||||
title:y_axis['title'],
|
||||
lines: y_axis['lines']
|
||||
lines: y_axis['lines'],
|
||||
start:y_axis['start'],
|
||||
step:y_axis['step'],
|
||||
end:y_axis['end']
|
||||
},
|
||||
padding: {
|
||||
left: 75
|
||||
@@ -283,6 +330,7 @@ openerp.base_graph.GraphView = openerp.base.Controller.extend({
|
||||
});
|
||||
}
|
||||
bar_chart.parse(_.values(abscissa_data), "json");
|
||||
jQuery("#"+self.elem_id+"-barchart").height(jQuery("#"+self.elem_id+"-barchart").height()+50);
|
||||
bar_chart.attachEvent("onItemClick", function(id) {
|
||||
self.open_list_view(bar_chart.get(id));
|
||||
});
|
||||
@@ -291,7 +339,7 @@ openerp.base_graph.GraphView = openerp.base.Controller.extend({
|
||||
var self = this;
|
||||
var chart = new dhtmlxchartChart({
|
||||
view:"pie3D",
|
||||
container:self.view_id+"-piechart",
|
||||
container:self.elem_id+"-piechart",
|
||||
value:"#"+self.operator_field+"#",
|
||||
pieInnerText:function(obj) {
|
||||
var sum = chart.sum("#"+self.operator_field+"#");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<t t-name="GraphView">
|
||||
<h2 class="oe_view_title"><t t-esc="fields_view.arch.attrs.string"/></h2>
|
||||
<div t-att-id="view_id+'-'+chart+'chart'" style="height:300px;position:relative;border:1px solid #A4BED4;"></div>
|
||||
<div t-att-id="elem_id+'-'+chart+'chart'" style="height:300px;position:relative;border:1px solid #A4BED4;"></div>
|
||||
</t>
|
||||
</template>
|
||||
Reference in New Issue
Block a user