An EmberJS echarts wrapper
ember install ember-cli-echarts
Before using this addon, you might want to checkout the echarts docs
All you need to get started is to pass in the data it should display via the option
parameter.
All chart specific options can be specified via the option
parameter.
// Basic area chart
option = {
xAxis: {
type: 'category',
boundaryGap: false,
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
},
yAxis: {
type: 'value'
},
series: [{
data: [820, 932, 901, 934, 1290, 1330, 1320],
type: 'line',
areaStyle: {}
}]
};
onEvents: {
click(param, echart) {
console.log(param, echart);
alert('chart clicked');
},
legendselectchanged(param, echart){
console.log(param, echart);
alert('chart legendselectchanged');
}
}
_t: null,
loadingOptions: {
text: '加载中...',
color: '#4413c2',
textColor: '#270240',
maskColor: 'rgba(194, 88, 86, 0.3)',
zlevel: 0
},
onChartReady(chart) {
set(this, '_t', setTimeout(() => {
chart.hideLoading();
}, 3000));
},
Custom theme
init() {
this._super(...arguments);
this.registerTheme();
set(this, 'theme', 'my_theme');
},
registerTheme() {
const colorPalette = [
'#c12e34','#e6b600','#0098d9','#2b821d',
'#005eaa','#339ca8','#cda819','#32a487'
];
echarts.registerTheme('my_theme', {
"color": colorPalette,
"title": {
"left": "center",
"y": "10",
"textStyle": {
"color": "#fff"
},
},
legend: {
"textStyle": {
"color": "#fff"
},
},
"backgroundColor": "#1c2e40",
});
}
Echarts Dark
theme
init() {
this._super(...arguments);
// echart default themes
set(this, 'theme', 'dark');
}
opts: {
devicePixelRatio: 1,
renderer: 'svg' // canvas of svg
width: '500px',
height: '500px'
}
Currently there are two helper actions provided:
This is called before echarts has been initialized.
beforeSetup(context, chart) {}
This is called after all chart options and data have been set, as well as after the chart has been created.
afterSetup(context, chart) {}
If it is a bug please open an issue on GitHub.
git clone
this repositorynpm install
bower install
ember server
- Visit your app at http://localhost:4200.
ember test
ember test --server
ember build
For more information on using ember-cli, visit http://www.ember-cli.com/.