-
Dante Aleo authoredDante Aleo authored
graph-element.component.ts 2.04 KiB
// 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/>.
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);
}
}