Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 32 additions & 7 deletions dist/angular-fusioncharts.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
columns: '@',
map: '@',
markers: '@',
initialized: '&'
initialized: '&',
datasourceDt: '=datasourceDt'
},
fcEvents = [
'beforelinkeditemopen',
Expand Down Expand Up @@ -197,6 +198,36 @@
return {
scope: scope,
link: function(scope, element, attrs) {
function updateData(key, data) {
scope.datasourceDt.key = data;
chart.setJSONData(scope.datasourceDt);
}

function createWatchersForAttrs(datasource) {
const keys = Object.keys(datasource);
keys.forEach(function(key) {
const isDeep = key !== 'data';
scope.$watch(
'datasourceDt.' + key,
function(newData, oldData) {
if (newData !== oldData && isDeep) updateData(key, newData);
},
isDeep
);
});
}

if (scope.datasourceDt) {
scope.$watch(
'datasourceDt.data',
function(newData, oldData) {
if (newData !== oldData) updateData(newData, 'data');
},
false
);
createWatchersForAttrs(scope.datasourceDt);
}

var observeConf = {
// non-data componenet observers
NDCObserver: {
Expand All @@ -221,7 +252,6 @@
datasource: {
ifExist: true,
observer: function(newVal) {
console.log('datasource');
if (dataStringStore.dataSource != newVal) {
dataStringStore.dataSource = newVal;
if (chartConfigObject.dataFormat === 'json') {
Expand Down Expand Up @@ -291,7 +321,6 @@
data: {
ifExist: true,
observer: function(newVal) {
console.log('data');
if (
chartConfigObject.dataFormat === 'json' &&
typeof chartConfigObject.dataSource == 'object' &&
Expand Down Expand Up @@ -587,7 +616,6 @@
},
setDataTimer,
setChartData = function() {
console.log('setChartData');
// clear previous dataUpdate timer
if (setDataTimer) {
clearTimeout(setDataTimer);
Expand All @@ -603,7 +631,6 @@
// chart.setJSONData(chartConfigObject.dataSource);
},
createFCChart = function() {
console.log('createFCChart');
// dispose if previous chart exists
if (chart && chart.dispose) {
chart.dispose();
Expand Down Expand Up @@ -688,8 +715,6 @@
}
}

console.log(attrs.datasource);

if (attrs.datasource) {
chartConfigObject.dataSource =
chartConfigObject.dataFormat === 'json'
Expand Down
2 changes: 1 addition & 1 deletion dist/angular-fusioncharts.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading