summaryrefslogtreecommitdiffstats
path: root/usecaseui-portal/src/app/components/charts/bar/bar.component.ts
blob: a7947f4edf5468b4b5253f50bd2717d173454ec0 (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
56
57
58
59
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: 40,
      width: 160,

    };
    this.barOption = {
      xAxis: this.initData.option.xAxis,
      yAxis: {
        type: 'category',
        show: false,
        axisTick: {
          show: false
        }
      },
      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;
  }

}