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 Exporting from 'highcharts/modules/exporting';
8
import ExportData from 'highcharts/modules/export-data';
9
import { TreemapHighchartsData } from '../../domain/treemap-highcharts-data';
10

    
11
More(Highcharts);
12
Tree(Highcharts);
13
Heatmap(Highcharts);
14
Exporting(Highcharts);
15
ExportData(Highcharts);
16

    
17
@Component({
18
  selector: 'app-treemap-highchart',
19
  templateUrl: './treemap-highcharts.component.html',
20
})
21

    
22
export class TreemapHighchartsComponent implements OnInit {
23

    
24
  @Input() chartTitle: string;
25
  @Input() chartSubtitle: string = '';
26
  @Input() chartData: TreemapHighchartsData[];
27
  @Input() color: string;
28

    
29
  @Input() height: number;
30

    
31
  Highcharts: typeof Highcharts = Highcharts;
32

    
33
  treeMapChartOptions = {};
34

    
35
  constructor() {}
36

    
37
  ngOnInit(): void {
38

    
39
    this.treeMapChartOptions = {
40
      chart: {
41
        type: 'treemap',
42
        height: this.height
43
      },
44
      title: {
45
        text: this.chartTitle,
46
        align: 'left',
47
        margin: 25,
48
        // style: {
49
        //   color: '#7A7A7A',
50
        //   fontSize: '18px'
51
        // }
52
      },
53
      subtitle: {
54
        text: this.chartSubtitle,
55
        align: 'left',
56
        margin: 25,
57
        // style: {
58
        //   color: '#7A7A7A',
59
        //   fontSize: '18px'
60
        // }
61
      },
62
      tooltip: {
63
        enabled: true
64
      },
65
      credits: {
66
        enabled: false
67
      },
68
      exporting: {
69
        enabled : true
70
      },
71
      colorAxis: {
72
        minColor: '#FFFFFF',
73
        maxColor: this.color,
74
        // maxColor: Highcharts.getOptions().colors[0]
75
      },
76
      series: [
77
        {
78
          type: 'treemap',
79
          layoutAlgorithm: 'squarified',
80
          data: this.chartData
81
        }
82
      ]
83
    };
84
  }
85

    
86
}
(2-2/2)