This is a Highcharts directive for Angular2.
{
"node": ">=5",
"angular2": ">=2.0.0",
"highcharts": ">=4.2"
}
# install angular-highcharts
npm i angular-highcharts --save
# install highcharts
npm i highcharts --save
# install highcharts typings (optional)
npm i @types/highcharts --save-dev
// app.module.js
import { ChartModule } from 'angular-highcharts';
@NgModule({
imports: [
...
ChartModule, // add ChartModule to your imports
...
],
...
})
export class AppModule { }
// chart.component.js
import { Chart } from 'angular-highcharts';
@Component({
...
template: `
<button (click)="add()">Add Point!</button>
<div [chart]="chart"></div>`,
...
})
export class ChartComponent {
chart = new Chart({
chart: {
type: 'line'
},
title: {
text: 'Linechart'
},
credits: {
enabled: false
},
series: [{
name: 'Line 1',
data: [1, 2, 3]
}]
});
// add point to chart serie
add() {
this.chart.addPoint(Math.floor(Math.random() * 10));
}
}
The Chart object.
Type: class
new Chart(options: HighchartsOptions)
ref: HighchartsChartObject
References to the HighchartsChartObject - Offical Chart API Docs
addPoint(point: Point, [serieIndex: number = 0]): void
Adds a point to a serie
removePoint(pointIndex: number, [serieIndex: number = 0], [redraw: boolean = true], [shift: boolean = false]): void
Removes a point from a serie
addSerie(serie: ChartSerie): void
Adds a serie to the chart
removeSerie(serieIndex: number): void
Remove serie to the chart
To use Highcharts modules you can import a refernce of the Highcharts
object and apply the module manually
import { Highcharts } from 'angular-highcharts';
require('highcharts/modules/exporting')(Highcharts);
import { Highcharts } from 'angular-highcharts';
import exporting from 'highcharts/modules/exporting';
exporting(Highcharts)
Offical Highcharts NPM Docs: http://www.highcharts.com/docs/getting-started/install-from-npm
- API Docs
- Highstocks support
- Highmaps support
MIT © Felix Itzenplitz