with angular 6.
Module:
Code: Select all
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { HighchartsChartModule } from 'highcharts-angular';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
HighchartsChartModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
component:
Code: Select all
import { Component } from '@angular/core';
import Highcharts from 'highcharts';
import HC_exporting from 'highcharts/modules/exporting';
HC_exporting(Highcharts);
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'app';
constructor() {
}
Highcharts = Highcharts;
chartOptions = {
series: [{
data: [1, 2, 3, 6, 9]
}],
exporting: {
enabled: true
},
yAxis :{
allowDecimals: false,
title: {
text: 'Data'
}
}
};
updateFromInput = false;
ngOnInit() {
}
update_chart() {
this.chartOptions.series = [{
data: [10, 20, 30]
}];
this.updateFromInput = true;
}
}
Code: Select all
<highcharts-chart id="container" [Highcharts]="Highcharts" [options]="chartOptions" [(update)]="updateFromInput"
[oneToOne]=true style="width: 100%; height: 400px; display: block;"></highcharts-chart>
Update Chart<button (click)="update_chart()">Update Chart</button>