import { Component , ElementRef , Inject , Input , LOCALE_ID } from '@angular/core' ; import { Options } from 'highcharts' ; import * as Highcharts from 'highcharts/highstock' ; import AnnotationsModule from 'highcharts/modules/annotations' ; import { annotations , StockChartDeprecatedDataPoint , } from './options/stock-chart-deprecated-options' ; AnnotationsModule ( Highcharts ) ; @ Component ( { selector : 'kirby-stock-chart-deprecated' , template : '' , styleUrls : [ './stock-chart-deprecated.component.scss' ] , } ) export class StockChartDeprecatedComponent { chartContainer : ElementRef ; private _data : StockChartDeprecatedDataPoint [ ] ; @ Input ( ) set data ( val ) { this . onDataChanges ( val ) ; } get data ( ) { return this . _data ; } private _options : Options ; @ Input ( ) set options ( val ) { this . onOptionsChanges ( val ) ; } get options ( ) { return this . _options ; } private _height = 300 ; @ Input ( ) set height ( height ) { this . _height = height ; if ( this . chart ) { this . chart . setSize ( null , height ) ; } } get height ( ) { return this . _height ; } @ Input ( ) description = '' ; @ Input ( ) showDataLabels = true ; chart : Highcharts . Chart ; constructor ( hostElement , @ Inject ( LOCALE_ID ) private locale ) { this . chartContainer = hostElement ; } onOptionsChanges ( options ) { this . _options = options ; this . chart = Highcharts . stockChart ( this . chartContainer . nativeElement , this . _options ) ; } onDataChanges ( data ) { this . _data = data ; if ( this . chart != null ) { this . chart . update ( { series : [ ] , } , false , true ) ; this . chart . removeAnnotation ( 'minmax' ) ; this . chart . update ( { series : [ { type : 'area' , data : data , } , ] , } , false , true ) ; this . chart . addAnnotation ( annotations ( this . locale ) , false ) ; this . chart . redraw ( ) ; } } }