Skip to content

Commit fb87c8e

Browse files
authored
Merge pull request #74 from dkamburov/master
Allow ig-chart to be init without defining data source
2 parents df14f33 + bb3e96e commit fb87c8e

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/igniteui-angular.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -405,12 +405,17 @@
405405
var diff = [], ds = scope.$eval(attrs.source), unbinder;
406406
var changeHandler = function (newValue, oldValue) {
407407
var $chartElem = $(element), chart = $chartElem.data("igDataChart");
408+
if (newValue && (oldValue === undefined || oldValue === null)) {
409+
$chartElem.igDataChart("option", "dataSource", newValue);
410+
return;
411+
}
408412
/* check for a change of the data source. In this case rebind */
409-
if (chart.dataSources[ chart._containerSourceID ].data() !== newValue) {
413+
if (chart.dataSources[ chart._containerSourceID ] &&
414+
chart.dataSources[ chart._containerSourceID ].data() !== newValue) {
410415
$chartElem.igDataChart("option", "dataSource", newValue);
411416
return;
412417
}
413-
if (newValue.length === oldValue.length) {
418+
if (newValue && oldValue && newValue.length === oldValue.length) {
414419
//attempt to optimize for value changes
415420
var equals = equalsDiff(newValue, oldValue, diff);
416421
if ((diff.length > 0) && !equals) {
@@ -424,7 +429,9 @@
424429
return;
425430
}
426431
}
427-
$chartElem.igDataChart("notifyClearItems", newValue);
432+
if (newValue) {
433+
$chartElem.igDataChart("notifyClearItems", newValue);
434+
}
428435
};
429436

430437
//handle push to track added data points, unbind and rebind watcher after.

0 commit comments

Comments
 (0)