Skip to content

Commit 892b982

Browse files
committed
kien.luu/always-create-chart-if-has-no-data
1 parent 24be2ec commit 892b982

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

angular-chart.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@
110110
chartClick: '=?',
111111
chartHover: '=?',
112112
chartDatasetOverride: '=?',
113-
chartForceUpdate: '=?'
113+
chartForceUpdate: '=?',
114+
chartDisplayWhenNoData: '=?'
114115
},
115116
link: function (scope, elem/*, attrs */) {
116117
if (useExcanvas) window.G_vmlCanvasManager.initElement(elem[0]);
@@ -133,7 +134,7 @@
133134
});
134135

135136
function watchData (newVal, oldVal) {
136-
if (! newVal || ! newVal.length || (Array.isArray(newVal[0]) && ! newVal[0].length)) {
137+
if (!scope.chartDisplayWhenNoData && (! newVal || ! newVal.length || (Array.isArray(newVal[0]) && ! newVal[0].length))) {
137138
destroyChart(scope);
138139
return;
139140
}
@@ -174,7 +175,7 @@
174175

175176
function createChart (type, scope, elem) {
176177
var options = getChartOptions(type, scope);
177-
if (! hasData(scope) || ! canDisplay(type, scope, elem, options)) return;
178+
if (!scope.chartDisplayWhenNoData && (! hasData(scope) || ! canDisplay(type, scope, elem, options))) return;
178179

179180
var cvs = elem[0];
180181
var ctx = cvs.getContext('2d');

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-chart.js",
3-
"version": "1.1.2",
3+
"version": "1.1.3",
44
"main": [
55
"./dist/angular-chart.js"
66
],

dist/angular-chart.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@
110110
chartClick: '=?',
111111
chartHover: '=?',
112112
chartDatasetOverride: '=?',
113-
chartForceUpdate: '=?'
113+
chartForceUpdate: '=?',
114+
chartDisplayWhenNoData: '=?'
114115
},
115116
link: function (scope, elem/*, attrs */) {
116117
if (useExcanvas) window.G_vmlCanvasManager.initElement(elem[0]);
@@ -133,7 +134,7 @@
133134
});
134135

135136
function watchData (newVal, oldVal) {
136-
if (! newVal || ! newVal.length || (Array.isArray(newVal[0]) && ! newVal[0].length)) {
137+
if (!scope.chartDisplayWhenNoData && (! newVal || ! newVal.length || (Array.isArray(newVal[0]) && ! newVal[0].length))) {
137138
destroyChart(scope);
138139
return;
139140
}
@@ -174,7 +175,7 @@
174175

175176
function createChart (type, scope, elem) {
176177
var options = getChartOptions(type, scope);
177-
if (! hasData(scope) || ! canDisplay(type, scope, elem, options)) return;
178+
if (!scope.chartDisplayWhenNoData && (! hasData(scope) || ! canDisplay(type, scope, elem, options))) return;
178179

179180
var cvs = elem[0];
180181
var ctx = cvs.getContext('2d');

dist/angular-chart.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)