Project

General

Profile

1
import { Component, Input, OnInit } from '@angular/core';
2

    
3
import * as  Highcharts from 'highcharts';
4
import More from 'highcharts/highcharts-more';
5
import Tree from 'highcharts/modules/treemap';
6
import Heatmap from 'highcharts/modules/heatmap';
7
import { TreemapHighchartsData } from '../../domain/treemap-highcharts-data';
8

    
9
More(Highcharts);
10
Tree(Highcharts);
11
Heatmap(Highcharts);
12

    
13
@Component({
14
  selector: 'app-treemap-highchart',
15
  templateUrl: './treemap-highcharts.component.html',
16
})
17

    
18
export class TreemapHighchartsComponent implements OnInit {
19

    
20
  @Input() chartTitle: string;
21
  @Input() chartData: TreemapHighchartsData[];
22
  @Input() color: string;
23

    
24
  Highcharts: typeof Highcharts = Highcharts;
25

    
26
  treeMapChartOptions = {};
27

    
28
  constructor() {}
29

    
30
  ngOnInit(): void {
31

    
32
    this.treeMapChartOptions = {
33
      chart: {
34
        type: 'treemap'
35
      },
36
      title: {
37
        text: this.chartTitle
38
      },
39
      tooltip: {
40
        enabled: true
41
      },
42
      credits: {
43
        enabled: false
44
      },
45
      colorAxis: {
46
        minColor: '#FFFFFF',
47
        maxColor: this.color,
48
        // maxColor: Highcharts.getOptions().colors[0]
49
      },
50
      series: [
51
        {
52
          type: 'treemap',
53
          layoutAlgorithm: 'squarified',
54
          data: this.chartData
55
        }
56
      ]
57
    };
58
  }
59

    
60
}
(2-2/2)