ngx-admin/src/app/pages/charts/echarts/echarts-bar-animation.component.ts

82 lines
1.9 KiB
TypeScript
Raw Normal View History

import { Component } from '@angular/core';
import { NgaThemeService } from '@akveo/nga-theme';
@Component({
selector: 'ngx-echarts-bar-animation',
2017-07-27 12:06:50 +03:00
template: `
<div echarts [options]="options" class="echart"></div>
`,
})
export class EchartsBarAnimationComponent {
options: any;
2017-07-27 12:06:50 +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;
this.options = {
2017-08-01 15:42:06 +03:00
backgroundColor: echarts.bg,
color: [echarts.barAnimation.colors],
legend: {
data: ['bar', 'bar2'],
align: 'left',
textStyle: {
2017-08-01 15:42:06 +03:00
color: echarts.legendTextColor,
},
2017-07-27 12:06:50 +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 12:06:50 +03:00
},
yAxis: {
axisLine: {
lineStyle: {
2017-08-01 15:42:06 +03:00
color: echarts.yAxisLineColor,
},
},
2017-07-27 12:06:50 +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 12:06:50 +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
}
}