Skip to content

Instantly share code, notes, and snippets.

@tchan
Last active November 16, 2018 17:36
Show Gist options
  • Save tchan/29454f72774bb45efb331483dd9e93c9 to your computer and use it in GitHub Desktop.
Save tchan/29454f72774bb45efb331483dd9e93c9 to your computer and use it in GitHub Desktop.
ChartJS update test
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'ChartJS Update Test',
testData: Ember.computed(function() {
return {
labels: ['hi', 'there', 'sir'],
datasets: [{
data: [1,2,3]
}]
};
}),
options: {
responsive: false,
legend: { display: false, },
},
actions: {
addData() {
var cdata = this.get('testData');
console.log('cdata', cdata);
cdata.datasets[0].data[2] = 5;
cdata.labels[2] = "New sir";
this.set('testData',cdata);
this.notifyPropertyChange('testData');
}
}
});
<h1>{{appName}}</h1>
<br>
<br>
{{outlet}}
<br>
<br>
{{ember-chart type='pie' data=testData height=300 width=300 options=options animate=true}}
<button {{action 'addData'}}>modify data</button>
{
"version": "0.12.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.12.0",
"ember-template-compiler": "2.12.0",
"ember-testing": "2.12.0"
},
"addons": {
"ember-data": "2.12.1",
"ember-cli-chart": "3.3.2"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment