Skip to content

Commit 442013a

Browse files
author
MICHAEL SCHULTZ
committed
Added an initialization guard for the watches, and added a stricter condition to auto-attach a chart type to line.
1 parent 799bc75 commit 442013a

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/zingchart-angularjs.js

+13-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,15 @@
1010
zcRender : '='
1111
},
1212
controller : ['$scope', '$element', '$attrs', function($scope, $element, $attrs){
13-
13+
var initializing = {
14+
json : true,
15+
values :true
16+
};
1417
$scope.$watchCollection('zcValues', function(){
18+
if(initializing.values){
19+
initializing.values = !initializing.values;
20+
return;
21+
}
1522
if($scope.zcValues){
1623
if(isMultiArray($scope.zcValues)){
1724
zingchart.exec($attrs.id, 'setseriesvalues', {
@@ -27,6 +34,10 @@
2734
});
2835

2936
$scope.$watch('zcJson', function(){
37+
if(initializing.json){
38+
initializing.json = !initializing.json;
39+
return;
40+
}
3041
if($attrs.zcJson){
3142
var _json = $scope.zcJson;
3243
//Inject values
@@ -47,7 +58,7 @@
4758
}
4859
}
4960
//Inject type
50-
if(!_json.type){
61+
if(JSON.stringify(_json).indexOf('type') === -1){
5162
_json.type = 'line';
5263
}
5364
else{

0 commit comments

Comments
 (0)