blob: 38a2fc0d1bf21ce3a80009923b2156cf916432a7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
import { Component, OnInit, Input } from '@angular/core';
import { SimpleChanges } from '@angular/core/src/metadata/lifecycle_hooks';
@Component({
selector: 'app-bar',
templateUrl: './bar.component.html',
styleUrls: ['./bar.component.less']
})
export class BarComponent implements OnInit {
// 图形数据
@Input() chartData;
// 初始化数据
@Input() initData;
constructor() { }
ngOnInit() {
this.initOpts = {
renderer: 'canvas',
height: 200,
width: 280,
};
this.barOption = {
tooltip: this.initData.option.tooltip,
grid: this.initData.option.grid,
xAxis: this.initData.option.xAxis,
yAxis:this.initData.option.yAxis,
series: this.initData.option.series
}
}
ngOnChanges(changes: SimpleChanges) {
// 当有实例的时候再执行,相当于第一次不执行下面方法
if (this.chartIntance) {
this.chartDataChange()
}
}
// 初始化图形高度
initOpts: any;
// 折线图配置
barOption: any;
// 实例对象
chartIntance: any;
// 数据变化
updateOption: any;
chartDataChange() {
this.updateOption = this.chartData;
}
chartInit(chart) {
this.chartIntance = chart;
}
}
|