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
        align: 'left',
39
        margin: 25,
40
        // style: {
41
        //   color: '#7A7A7A',
42
        //   fontSize: '18px'
43
        // }
44
      },
45
      tooltip: {
46
        enabled: true
47
      },
48
      credits: {
49
        enabled: false
50
      },
51
      exporting: {
52
        enabled : true
53
      },
54
      colorAxis: {
55
        minColor: '#FFFFFF',
56
        maxColor: this.color,
57
        // maxColor: Highcharts.getOptions().colors[0]
58
      },
59
      series: [
60
        {
61
          type: 'treemap',
62
          layoutAlgorithm: 'squarified',
63
          data: this.chartData
64
        }
65
      ]
66
    };
67
  }
68

    
69
}
(2-2/2)