ember-highcharts-mixin
v0.0.2
Published
A mixin that allows you to easily create highcharts components by taking care of data binding and redrawing for you.
Downloads
6
Readme
Highcharts-mixin
Takes care of the hard stuff so you can focus on building charts.
Installation
ember install ember-highcharts-mixin
Usage
This mixin will automagicify a component with auto chart-drawing and refreshing. Include it with:
import HighchartsMixin from 'ember-highcharts-mixin';
At the top of your component's file. Your component only needs to provide two things:
- An
options
property that returns a POJO of Highcharts options. This would be the same object you'd pass to Highcharts, see documentation. The only difference is you won't include yourseries
here. - A
series
property that returns an array of objects representing your series. This would be the same array you'd normally have as aseries
property of the Highcharts options object.
And that's it! You can now place your component in your templates.
Why the separation of series
from options
? Because it's very unlikely your data is already formatted as Highcharts series. And each series is unique to that specific chart. Separating the series
allows you to define it as a computed property that takes in data from elsewhere and massages it into the format you want for this particular chart. Everything is live bound, so if the data changes, your series
array will change, and your chart will redraw.