Newer
Older
// This file is part of the project Pinsis-Portal.
// Copyright (C),2018, by C3SL(Centro de Computação Científica e
// Software Live)
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
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
import { Component, ViewChild, ElementRef, AfterViewInit, Input} from '@angular/core';
import { chart } from 'highcharts';
import { Highcharts } from 'angular-highcharts';
@Component({
selector: 'graph-element',
templateUrl: './graph-element.component.html',
styleUrls: [ './graph-element.component.scss']
})
export class GraphElementComponent implements AfterViewInit {
chart: Highcharts.ChartObject;
@ViewChild('graphTarget') graphTarget: ElementRef;
@Input() options: Highcharts.Options;
constructor() {
Highcharts.setOptions({
lang: {
months: ['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro'],
weekdays: ['Domingo', 'Segunda', 'Terça', 'Quarta', 'Quinta', 'Sexta', 'Sábado'],
shortMonths: ['Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez']
}
})
}
ngAfterViewInit() {
this.chart = chart(this.graphTarget.nativeElement, this.options);
}
public reset(graphOptions: Highcharts.Options) {
this.options = graphOptions;
this.chart.destroy();
this.chart = chart(this.graphTarget.nativeElement, this.options);
}
}