chart fixes
This commit is contained in:
@@ -87,13 +87,20 @@ Espo.define('crm:views/dashlets/abstract/chart', ['views/dashlets/abstract/base'
|
||||
if (!this.isRendered()) return;
|
||||
setTimeout(function () {
|
||||
this.adjustContainer();
|
||||
if (this.isNoData()) {
|
||||
this.showNoData();
|
||||
return;
|
||||
}
|
||||
this.draw();
|
||||
}.bind(this), 50);
|
||||
}, this);
|
||||
|
||||
|
||||
$(window).on('resize.chart' + this.id, function () {
|
||||
this.adjustContainer();
|
||||
if (this.isNoData()) {
|
||||
this.showNoData();
|
||||
return;
|
||||
}
|
||||
this.draw();
|
||||
}.bind(this));
|
||||
|
||||
@@ -212,13 +219,13 @@ Espo.define('crm:views/dashlets/abstract/chart', ['views/dashlets/abstract/base'
|
||||
this.fetch(function (data) {
|
||||
this.chartData = this.prepareData(data);
|
||||
|
||||
this.adjustContainer();
|
||||
|
||||
if (this.isNoData()) {
|
||||
this.showNoData();
|
||||
return;
|
||||
}
|
||||
|
||||
this.adjustContainer();
|
||||
|
||||
setTimeout(function () {
|
||||
if (!this.$container.length || !this.$container.is(":visible")) return;
|
||||
this.draw();
|
||||
|
||||
@@ -58,9 +58,12 @@ Espo.define('crm:views/dashlets/opportunities-by-stage', 'crm:views/dashlets/abs
|
||||
|
||||
this.stageList = [];
|
||||
|
||||
this.isEmpty = true;
|
||||
|
||||
var data = [];
|
||||
var i = 0;
|
||||
d.forEach(function (item) {
|
||||
if (item.value) this.isEmpty = false;
|
||||
var o = {
|
||||
data: [[item.value, d.length - i]],
|
||||
label: this.getLanguage().translateOption(item.stage, 'stage', 'Opportunity'),
|
||||
@@ -91,6 +94,10 @@ Espo.define('crm:views/dashlets/opportunities-by-stage', 'crm:views/dashlets/abs
|
||||
this.currencySymbol = this.getMetadata().get(['app', 'currency', 'symbolMap', this.currency]) || '';
|
||||
},
|
||||
|
||||
isNoData: function () {
|
||||
return this.isEmpty;
|
||||
},
|
||||
|
||||
draw: function () {
|
||||
var self = this;
|
||||
this.flotr.draw(this.$container.get(0), this.chartData, {
|
||||
|
||||
@@ -53,7 +53,7 @@ Espo.define('crm:views/dashlets/sales-by-month', 'crm:views/dashlets/abstract/ch
|
||||
},
|
||||
|
||||
isNoData: function () {
|
||||
return !this.monthList.length;
|
||||
return this.isEmpty;
|
||||
},
|
||||
|
||||
prepareData: function (response) {
|
||||
@@ -69,6 +69,8 @@ Espo.define('crm:views/dashlets/sales-by-month', 'crm:views/dashlets/abstract/ch
|
||||
|
||||
this.chartData = [];
|
||||
|
||||
this.isEmpty = true;
|
||||
|
||||
var mid = 0;
|
||||
if (values.length) {
|
||||
mid = values.reduce(function(a, b) {return a + b}) / values.length;
|
||||
@@ -79,6 +81,7 @@ Espo.define('crm:views/dashlets/sales-by-month', 'crm:views/dashlets/abstract/ch
|
||||
var max = 0;
|
||||
|
||||
values.forEach(function (value, i) {
|
||||
if (value) this.isEmpty = false;
|
||||
if (value && value > max) {
|
||||
max = value;
|
||||
}
|
||||
|
||||
@@ -50,10 +50,17 @@ Espo.define('crm:views/dashlets/sales-pipeline', 'crm:views/dashlets/abstract/ch
|
||||
return url;
|
||||
},
|
||||
|
||||
isNoData: function () {
|
||||
return this.isEmpty;
|
||||
},
|
||||
|
||||
prepareData: function (response) {
|
||||
var d = [];
|
||||
|
||||
this.isEmpty = true;
|
||||
|
||||
response.dataList.forEach(function (item) {
|
||||
if (item.value) this.isEmpty = false;
|
||||
d.push({
|
||||
stageTranslated: this.getLanguage().translateOption(item.stage, 'stage', 'Opportunity'),
|
||||
value: item.value,
|
||||
|
||||
Reference in New Issue
Block a user