2017-07-26 19:59:47 +03:00
|
|
|
import { Component } from '@angular/core';
|
2017-07-27 17:21:38 +03:00
|
|
|
import { NgaThemeService } from '@akveo/nga-theme';
|
2017-07-26 19:59:47 +03:00
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'ngx-echarts-bar-animation',
|
2017-07-27 12:06:50 +03:00
|
|
|
template: `
|
|
|
|
|
<div echarts [options]="options" class="echart"></div>
|
|
|
|
|
`,
|
2017-07-26 19:59:47 +03:00
|
|
|
})
|
|
|
|
|
export class EchartsBarAnimationComponent {
|
2017-07-27 17:21:38 +03:00
|
|
|
options: any;
|
2017-07-27 12:06:50 +03:00
|
|
|
|
2017-07-27 17:21:38 +03:00
|
|
|
constructor(private theme: NgaThemeService) {
|
|
|
|
|
this.theme.getJsTheme().subscribe(config => {
|
|
|
|
|
const xAxisData = [];
|
|
|
|
|
const data1 = [];
|
|
|
|
|
const data2 = [];
|
|
|
|
|
|
2017-08-01 15:42:06 +03:00
|
|
|
const echarts: any = config.variables.echarts;
|
|
|
|
|
|
2017-07-27 17:21:38 +03:00
|
|
|
this.options = {
|
2017-08-01 15:42:06 +03:00
|
|
|
backgroundColor: echarts.bg,
|
|
|
|
|
color: [echarts.barAnimation.colors],
|
2017-07-27 17:21:38 +03:00
|
|
|
legend: {
|
|
|
|
|
data: ['bar', 'bar2'],
|
|
|
|
|
align: 'left',
|
|
|
|
|
textStyle: {
|
2017-08-01 15:42:06 +03:00
|
|
|
color: echarts.legendTextColor,
|
2017-07-27 17:21:38 +03:00
|
|
|
},
|
2017-07-27 12:06:50 +03:00
|
|
|
},
|
2017-07-27 17:21:38 +03:00
|
|
|
xAxis: {
|
|
|
|
|
data: xAxisData,
|
|
|
|
|
silent: false,
|
|
|
|
|
splitLine: {
|
|
|
|
|
show: false,
|
|
|
|
|
},
|
|
|
|
|
axisLine: {
|
|
|
|
|
lineStyle: {
|
2017-08-01 15:42:06 +03:00
|
|
|
color: echarts.xAxisLineColor,
|
2017-07-27 17:21:38 +03:00
|
|
|
},
|
|
|
|
|
},
|
2017-07-27 12:06:50 +03:00
|
|
|
},
|
2017-07-27 17:21:38 +03:00
|
|
|
yAxis: {
|
|
|
|
|
axisLine: {
|
|
|
|
|
lineStyle: {
|
2017-08-01 15:42:06 +03:00
|
|
|
color: echarts.yAxisLineColor,
|
2017-07-27 17:21:38 +03:00
|
|
|
},
|
|
|
|
|
},
|
2017-07-27 12:06:50 +03:00
|
|
|
},
|
2017-07-27 17:21:38 +03:00
|
|
|
series: [
|
|
|
|
|
{
|
|
|
|
|
name: 'bar',
|
|
|
|
|
type: 'bar',
|
|
|
|
|
data: data1,
|
|
|
|
|
animationDelay: function(idx) {
|
|
|
|
|
return idx * 10;
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'bar2',
|
|
|
|
|
type: 'bar',
|
|
|
|
|
data: data2,
|
|
|
|
|
animationDelay: function(idx) {
|
|
|
|
|
return idx * 10 + 100;
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
animationEasing: 'elasticOut',
|
|
|
|
|
animationDelayUpdate: function(idx) {
|
|
|
|
|
return idx * 5;
|
2017-07-27 12:06:50 +03:00
|
|
|
},
|
2017-07-27 17:21:38 +03:00
|
|
|
};
|
2017-07-27 12:06:50 +03:00
|
|
|
|
2017-07-27 17:21:38 +03:00
|
|
|
for (let i = 0; i < 100; i++) {
|
|
|
|
|
xAxisData.push('Category ' + i);
|
|
|
|
|
data1.push((Math.sin(i / 5) * (i / 5 - 10) + i / 6) * 5);
|
|
|
|
|
data2.push((Math.cos(i / 5) * (i / 5 - 10) + i / 6) * 5);
|
|
|
|
|
}
|
|
|
|
|
});
|
2017-07-27 12:06:50 +03:00
|
|
|
}
|
2017-07-26 19:59:47 +03:00
|
|
|
}
|