Skip to content

sballan/angular-highcharts

 
 

Repository files navigation

angular-highcharts

NPM version NPM downloads Build Status

This is a Highcharts directive for Angular2.

Requirements

{
  "node": ">=5",
  "angular2": ">=2.0.0",
  "highcharts": ">=4.2"
}

Installation

# install angular-highcharts
npm i angular-highcharts --save

# install highcharts
npm i highcharts --save

# install highcharts typings (optional)
npm i @types/highcharts --save-dev

Usage Example

// 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));
  }
}

API Docs

Chart

The Chart object.

Type: class

Constructor

new Chart(options: HighchartsOptions)

Properties

ref: HighchartsChartObject

References to the HighchartsChartObject - Offical Chart API Docs

Methods

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

Using Highcharts modules

To use Highcharts modules you can import a refernce of the Highcharts object and apply the module manually

commonjs (webpack)

import { Highcharts } from 'angular-highcharts';
require('highcharts/modules/exporting')(Highcharts);

system (SystemJS)

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

Demo

Link

Coming soon

  • API Docs
  • Highstocks support
  • Highmaps support

License

MIT © Felix Itzenplitz

About

Highcharts directive for Angular2

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 90.2%
  • JavaScript 9.8%