Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Commit

Permalink
add data observer
Browse files Browse the repository at this point in the history
  • Loading branch information
eterna2 committed Aug 1, 2016
1 parent e4ca986 commit 8fdd104
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ A [PolymerJS](https://www.polymer-project.org) custom element for rendering inte
bower install vega-element
```

# important note

You need to import the d3, d3-layout-cloud, geo-projection, topojson dependencies separately (in the right order) for vega to include the plugins properly.

e.g.
```
<link rel="import" href="./d3.html">
<link rel="import" href="./d3-layout-cloud.html">
<link rel="import" href="./vega-element.html">
```

# documentation

Details and demo can be found at the [Component Page](https://datagovsg.github.io/vega-element)
7 changes: 6 additions & 1 deletion es5/vega-behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
}
},

observers: ["parse(spec)", "updateSignal(signal,view)", "getData(requestData,view)", "_updateSignalListeners(_diff.added,_diff.removed,view)"],
observers: ["parse(spec)", "updateSignal(signal,view)", "getData(requestData,view)", "_updateSignalListeners(_diff.added,_diff.removed,view)", '_updateData(view,data)'],

/*
* Parse a Vega JSON specification or URL. Updates the **_chart** attribute. Automatically called when **spec** is updated.
Expand Down Expand Up @@ -158,6 +158,11 @@
return this.lastData;
},

_updateData: function _updateData(view, data) {
if (!view || !data) return;
view.data(data).update({ duration: 800 });
},

_observeSignalsChanged: function _observeSignalsChanged(val, old) {
this._diff = this._difference(val, old);
},
Expand Down
7 changes: 6 additions & 1 deletion es6/vega-behavior.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@
"parse(spec)",
"updateSignal(signal,view)",
"getData(requestData,view)",
"_updateSignalListeners(_diff.added,_diff.removed,view)"
"_updateSignalListeners(_diff.added,_diff.removed,view)",
'_updateData(view,data)'
],


Expand Down Expand Up @@ -162,6 +163,10 @@
return this.lastData;
},

_updateData: function(view,data){
if (!view || !data) return;
view.data(data).update({duration:800});
},

_observeSignalsChanged: function(val,old){
this._diff = this._difference(val,old);
Expand Down
7 changes: 6 additions & 1 deletion vega-behavior.html
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
}
},

observers: ["parse(spec)", "updateSignal(signal,view)", "getData(requestData,view)", "_updateSignalListeners(_diff.added,_diff.removed,view)"],
observers: ["parse(spec)", "updateSignal(signal,view)", "getData(requestData,view)", "_updateSignalListeners(_diff.added,_diff.removed,view)", '_updateData(view,data)'],

/*
* Parse a Vega JSON specification or URL. Updates the **_chart** attribute. Automatically called when **spec** is updated.
Expand Down Expand Up @@ -162,6 +162,11 @@
return this.lastData;
},

_updateData: function _updateData(view, data) {
if (!view || !data) return;
view.data(data).update({ duration: 800 });
},

_observeSignalsChanged: function _observeSignalsChanged(val, old) {
this._diff = this._difference(val, old);
},
Expand Down

0 comments on commit 8fdd104

Please sign in to comment.