Skip to content

Instantly share code, notes, and snippets.

@jelhan
Created November 1, 2016 12:13
Show Gist options
  • Save jelhan/e2d9c2b794a64d18201e5bcc03480387 to your computer and use it in GitHub Desktop.
Save jelhan/e2d9c2b794a64d18201e5bcc03480387 to your computer and use it in GitHub Desktop.
aomran/ember-cli-chart #50
import Ember from 'ember';
const { computed } = Ember;
export default Ember.Controller.extend({
data: computed(function(){
var labels = ["January", "February", "March", "April", "May", "June"];
return {
labels: labels,
datasets: [
{
label: "My First dataset",
fillColor: "rgba(220,220,220,0.2)",
strokeColor: "rgba(220,220,220,1)",
pointColor: "rgba(220,220,220,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(220,220,220,1)",
data: [50, 10, 80, 81, 56, 55, 40]
},
{
label: "My Second dataset",
fillColor: "rgba(151,187,205,0.2)",
strokeColor: "rgba(151,187,205,1)",
pointColor: "rgba(151,187,205,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(151,187,205,1)",
data: [28, 48, 40, 19, 86, 27, 90]
}
]
};
}),
isBarChart: computed.equal('type', 'bar'),
isLineChart: computed.equal('type', 'line'),
type: 'line'
});
<h1>updating ember-cli-chart type option</h1>
<p>
Charttype is: {{type}}<br/>
Select another type:
<select onchange={{action (mut type) value="target.value"}}>
<option selected={{if isLineChart 'selected'}} value="line">line</option>
<option selected={{if isBarChart 'selected'}} value="bar">bar</option>
</select>
</p>
<p>
{{ember-chart type=type data=data}}
</p>
{
"version": "0.10.6",
"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.6.0",
"ember-template-compiler": "2.6.0",
"ember-testing": "2.6.0"
},
"addons": {
"ember-cli-chartjs": "*"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment