angular-highcharts
TypeScript icon, indicating that this package has built-in type declarations

17.0.1 • Public • Published

angular-highcharts

NPM version NPM downloads

This is a directive for an easy usage of Highcharts with angular.

Requirements

{
  "angular": "^15.1.1",
  "highcharts": "^10.3.3"
}

Installation

yarn

# install angular-highcharts and highcharts
yarn add angular-highcharts highcharts

npm

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

Usage Example

// app.module.ts
import { ChartModule } from 'angular-highcharts';

@NgModule({
  imports: [
    ChartModule // add ChartModule to your imports
  ]
})
export class AppModule {}
// chart.component.ts
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: Options)

Properties

ref: Highcharts.Chart;

Deprecated. Please use ref$.

ref$: Observable<Highcharts.Chart>

Observable that emits a Highcharts.Chart - Official 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

addSeries(series: ChartSerie): void

Adds a series to the chart

removeSeries(seriesIndex: number): void

Remove series from the chart

StockChart

The Chart object.

Type: class

Constructor

new StockChart(options);

Properties

ref: Highstock.Chart;

Deprecated. Please use ref$.

ref$: Observable<Highstock.Chart>

Observable that emits a Highstock.Chart

MapChart

The Chart object.

Type: class

Constructor

new MapChart(options);

Properties

ref;

Deprecated. Please use ref$.

ref$;

Observable that emits a Highmaps.Chart

Using Highcharts modules

To use Highcharts modules you have to import them and provide them in a factory (required for aot). You can find the list of available modules in the highcharts folder ls -la node_modules/highcharts/modules.

Hint: Highcharts-more is a exception, you find this module in the root folder. Don't forget to use the modules with the .src suffix, minimized highcharts modules are not importable.

Example

// app.module.ts
import { ChartModule, HIGHCHARTS_MODULES } from 'angular-highcharts';
import * as more from 'highcharts/highcharts-more.src';
import * as exporting from 'highcharts/modules/exporting.src';

@NgModule({
  providers: [
    { provide: HIGHCHARTS_MODULES, useFactory: () => [ more, exporting ] } // add as factory to your providers
  ]
})
export class AppModule { }

Troubleshooting

Compile Issues

If you expiring typing errors while you build/serve your angular app the following could be helpful:

// override options type with <any>
chart = new Chart({ options } as any);

This is very useful when using gauge chart type.

Loading Highcharts Modules manually

See Official Highcharts Docs: http://www.highcharts.com/docs/getting-started/install-from-npm

Demo

License

MIT © Felix Itzenplitz

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
17.0.14,968latest
5.2.13522five
6.2.6190six
4.1.232four

Version History

VersionDownloads (Last 7 Days)Published
17.0.14,968
17.0.0607
16.0.04,018
15.0.11,245
15.0.013
14.1.71,232
14.1.63
14.1.528
13.0.11,270
13.0.089
12.0.01,273
11.4.0287
11.3.1123
11.3.01
11.2.110
11.2.227
11.2.01
10.0.1737
10.0.06
9.0.11530
9.0.102
9.0.92
9.0.82
9.0.251
8.0.3749
8.0.210
8.0.12
8.0.08
7.2.0413
7.1.02
7.0.2142
7.0.13
7.0.03
6.2.6190
6.2.51
6.2.41
6.2.34
6.2.21
6.2.13
6.2.03
4.1.232
6.1.51
5.2.13522
6.1.48
6.1.321
6.1.22
6.1.110
6.1.02
6.0.05
5.2.128
5.2.111
5.2.1013
5.2.83
5.2.75
5.2.64
5.2.53
5.2.45
5.2.31
5.2.21
5.2.14
4.1.028
5.2.02
5.1.23
5.1.11
5.1.01
5.0.71
5.0.62
4.0.7242
5.0.57
4.0.62
5.0.41
5.0.34
5.0.21
5.0.11
5.0.02
4.0.51
4.0.42
4.0.31
4.0.23
4.0.11
4.0.01
3.5.24
3.5.12
3.5.02
3.4.81
3.4.72
3.4.61
3.4.51
3.4.41
3.4.32
3.4.21
3.4.11
3.4.02
3.3.61
3.3.52
3.3.41
3.3.32
3.3.12
3.3.01
3.2.11
3.2.01
3.1.42
3.1.32
3.1.21
3.1.12
3.1.02
3.0.51
3.0.42
3.0.31
3.0.21
3.0.11
3.0.01
2.0.015
1.1.81
1.1.71
1.1.65
1.1.52
1.1.42
1.1.31
1.1.22
1.1.11
1.1.02
1.0.31
1.0.22
1.0.01
0.7.22
0.7.11
0.7.01
0.6.61
0.6.52
0.6.41
0.6.32
0.6.22
0.6.11
0.6.01
0.5.71
0.5.63
0.5.52
0.5.41
0.5.32
0.5.22
0.5.13
0.5.01
0.4.01
0.3.32
0.3.21
0.3.11
0.3.01
0.2.41
0.2.31
0.2.22
0.2.13
0.2.01
0.1.71
0.1.62
0.1.51
0.1.42
0.1.31
0.1.21
0.1.11
0.1.01
0.0.111

Package Sidebar

Install

npm i angular-highcharts

Weekly Downloads

19,155

Version

17.0.1

License

MIT

Unpacked Size

84.3 kB

Total Files

22

Last publish

Collaborators

  • cebor