An Angular wrapper for Highcharts, providing easy integration of Highcharts, Highstock, Highmaps, and Highcharts Gantt charts into your Angular applications.
🚀 Explore the live demo gallery → — every chart type in action.
- Requirements
- Installation
- Usage
- API Documentation
- Using Highcharts Modules
- Troubleshooting
- Demo
- Contributing
- License
| Package | Version |
|---|---|
| Angular | >=22.0.0 |
| Highcharts | >=12.0.0 |
Install both angular-highcharts and highcharts:
npm install --save angular-highcharts highchartsyarn add angular-highcharts highchartspnpm add angular-highcharts highchartsImport ChartModule in your Angular module:
// app.module.tsimport{ChartModule}from'angular-highcharts';
@NgModule({imports: [ChartModule// Add ChartModule to your imports]})exportclassAppModule{}// chart.component.tsimport{Component}from'@angular/core';import{Chart}from'angular-highcharts';
@Component({selector: 'app-chart',template: ` <button (click)="add()">Add Point</button> <div [chart]="chart"></div> `})exportclassChartComponent{chart=newChart({chart: {type: 'line'},title: {text: 'Line Chart Example'},credits: {enabled: false},series: [{name: 'Line 1',data: [1,2,3],type: 'line'}]});// Add a point to the chart seriesadd(){this.chart.addPoint(Math.floor(Math.random()*10));}}Use the ref$ observable to access the Highcharts chart instance:
import{Component,OnInit}from'@angular/core';import{Chart}from'angular-highcharts';exportclassChartComponentimplementsOnInit{chart=newChart({// ... chart options});ngOnInit(){this.chart.ref$.subscribe(chart=>{// Access the Highcharts.Chart instanceconsole.log(chart);// Use Highcharts API methodschart.setTitle({text: 'Updated Title'});});}}Highcharts events are configured directly in the options object — there is no separate
Angular API for them. Set chart-level events under chart.events, and series/point events
under plotOptions:
chart=newChart({chart: {type: 'line',events: {load: ()=>console.log('chart loaded'),click: (e)=>console.log('chart clicked',e)}},plotOptions: {series: {events: {legendItemClick: (e)=>console.log('legend item clicked',e)},point: {events: {click: (e)=>this.onPointClick(e)}}}},series: [{type: 'line',data: [1,2,3]}]});Use arrow functions (or .bind(this)) for any handler that needs access to your component
instance.
Themes are applied with Highcharts.setOptions() on the same Highcharts instance the
library uses. Import it from the ESM .src entry point and call setOptions() before
creating a chart:
importHighchartsfrom'highcharts/esm/highcharts.src';Highcharts.setOptions({colors: ['#2b908f','#90ee7e','#f45b5b'],chart: {backgroundColor: '#2a2a2b'}});To switch themes at runtime, call setOptions() with the new theme and then re-create the
chart — assigning a new Chart instance to the [chart] input re-initializes it.
For simple point/series changes, use the Chart mutation helpers
(addPoint, removePoint, addSeries, removeSeries). For anything else, reach the live
instance through ref$ and call the Highcharts API directly:
this.chart.ref$.subscribe(chart=>{chart.series[0].setData([4,5,6]);// replace a series' datachart.update({title: {text: 'Updated'}});// update any options});Standard Highcharts chart for line, bar, pie, and other basic chart types.
Type:class
newChart(options: Highcharts.Options)Observable that emits the initialized Highcharts.Chart instance. Use this to access the chart API.
See Official Highcharts API Docs
chart.ref$.subscribe(chartInstance=>{// Work with the chartchartInstance.setTitle({text: 'New Title'});});addPoint(point: number | [number, number] | Highcharts.PointOptionsObject, serieIndex?: number, redraw?: boolean, shift?: boolean): void
Adds a point to a series.
Parameters:
point- The point to add (number, tuple, or object)serieIndex- Index of the series (default: 0)redraw- Whether to redraw the chart (default: true)shift- Whether to shift the first point off (default: false)
Example:
this.chart.addPoint(10);this.chart.addPoint([Date.now(),25],0,true,false);Removes a point from a series.
Parameters:
pointIndex- Index of the point to removeserieIndex- Index of the series (default: 0)
Adds a new series to the chart.
Example:
this.chart.addSeries({name: 'New Series',data: [1,2,3,4],type: 'line'});Removes a series from the chart by index.
Initializes the chart. Called automatically by the directive.
Destroys the chart and cleans up resources.
Highstock chart for financial and time-series data with advanced features like range selectors and navigator.
Type:class
newStockChart(options: Highcharts.Options)Observable that emits the initialized Highstock chart instance.
import{StockChart}from'angular-highcharts';stockChart=newStockChart({rangeSelector: {selected: 1},series: [{name: 'Stock Price',data: [[Date.UTC(2023,0,1),100],[Date.UTC(2023,0,2),105]],type: 'line'}]});Highmaps chart for geographical data visualization.
Type:class
newMapChart(options: Highcharts.Options)Observable that emits the initialized Highmaps chart instance.
import{MapChart}from'angular-highcharts';importworldMapfrom'@highcharts/map-collection/custom/world.geo.json';mapChart=newMapChart({chart: {map: worldMap},title: {text: 'World Map'},series: [{type: 'map',name: 'Countries',data: [/* map data */]}]});Highcharts Gantt chart for project management and scheduling visualization.
Type:class
newHighchartsGantt(options: Highcharts.Options)Observable that emits the initialized Gantt chart instance.
import{HighchartsGantt}from'angular-highcharts';ganttChart=newHighchartsGantt({title: {text: 'Project Timeline'},series: [{type: 'gantt',name: 'Tasks',data: [/* gantt data */]}]});Highcharts provides additional modules for extended functionality (exporting, 3D charts, annotations, etc.). To use these modules with angular-highcharts:
- Use ESM imports: Import from
highcharts/esm/for proper tree-shaking and module resolution - Use
.srcsuffix: Import modules with.src.in the path for AOT compatibility - Default imports: Use default imports (recommended) or namespace imports
- Factory pattern: Provide modules using a factory function (required for AOT)
- Location: Most modules are in
highcharts/esm/modules/, excepthighcharts-more.srcwhich is in the root
You can find available modules in your node_modules/highcharts/esm/modules/ directory:
ls -la node_modules/highcharts/esm/modules/Popular modules include:
exporting.src- Chart export functionalityexport-data.src- Export chart data to CSV/Excelaccessibility.src- Accessibility featuresannotations.src- Chart annotationsboost.src- Performance boost for large datasetsdrilldown.src- Drilldown functionalityno-data-to-display.src- Message when no data available
// app.module.tsimport{ChartModule,HIGHCHARTS_MODULES}from'angular-highcharts';importmorefrom'highcharts/esm/highcharts-more.src';importexportingfrom'highcharts/esm/modules/exporting.src';importexportDatafrom'highcharts/esm/modules/export-data.src';importaccessibilityfrom'highcharts/esm/modules/accessibility.src';
@NgModule({imports: [ChartModule],providers: [{provide: HIGHCHARTS_MODULES,useFactory: ()=>[more,exporting,exportData,accessibility]}]})exportclassAppModule{}After registering modules, you can use their features in your chart options:
chart=newChart({chart: {type: 'line'},exporting: {enabled: true,// Enabled by exporting modulebuttons: {contextButton: {menuItems: ['downloadPNG','downloadJPEG','downloadPDF']}}},// ... other options});If you encounter TypeScript errors when building or serving your Angular app, especially with specialized chart types like gauges or custom options:
// Cast options to any to bypass type checkingchart=newChart({// gauge or custom options}asany);This is particularly useful for:
- Gauge charts
- Custom chart types
- Advanced configurations not fully typed in
@types/highcharts
Problem:Cannot find module 'highcharts/modules/exporting.src'
Solution: Ensure you're using the .src suffix and default imports:
// ✅ Correct - ESM default import (recommended)importexportingfrom'highcharts/esm/modules/exporting.src';// ✅ Also works - Namespace import (still supported)import*asexportingfrom'highcharts/esm/modules/exporting.src';// ❌ Wrong - Missing .src suffiximportexportingfrom'highcharts/esm/modules/exporting';Note: This library uses ESM imports internally (highcharts/esm/...). Both default and namespace import styles work for module registration.
Common causes:
ChartModulenot imported in your module- Chart container has no height - add CSS:
div { height: 400px; } - Chart initialization happens before the view is ready - use
ngAfterViewInit()orref$observable
Highcharts only auto-resizes on window resize — not when its container changes size (for
example inside a grid, splitter, or mat-card). Call reflow() on the live instance when the
container resizes:
this.chart.ref$.subscribe(chart=>{constobserver=newResizeObserver(()=>chart.reflow());observer.observe(hostElement);// the element wrapping the chart});Highcharts renders SVG through the DOM and accesses window/document, so it cannot run
during server rendering. Only render the chart element in the browser:
import{Component,PLATFORM_ID,inject}from'@angular/core';import{isPlatformBrowser}from'@angular/common';import{Chart}from'angular-highcharts';
@Component({selector: 'app-chart',template: ` @if (isBrowser) { <div [chart]="chart"></div> } `})exportclassChartComponent{isBrowser=isPlatformBrowser(inject(PLATFORM_ID));chart=newChart({/* ... */});}This keeps the [chart] directive (and therefore Highcharts) from initializing on the server.
The older Cannot read property 'parts/…' of undefined errors came from the legacy build; the
current ESM build behaves better, but Highcharts must still never render server-side.
A Highcharts error #17 — or a chart type that silently renders nothing — almost always means
the module that provides that series type isn't registered. Types such as gauge /
solidgauge (need highcharts-more), sankey, heatmap, treemap, dependency-wheel, and
3D charts live in separate modules. Register them via
HIGHCHARTS_MODULES.
Always destroy charts in ngOnDestroy():
ngOnDestroy(){this.chart.destroy();}- 🚀 Live demo gallery — an interactive showcase of every chart type, deployed from this repo on each release.
- 💻 Demo source code — the Angular app behind the gallery.
- 🧪 Playground on StackBlitz — quick in-browser experiments.
We welcome contributions! Please see our Contributing Guide for details on:
- Setting up your development environment
- Coding standards and conventions
- Commit message guidelines
- Pull request process
Before submitting a PR, please:
- Check existing issues and PRs
- Follow the commit message format
- Add tests for new features
- Update documentation as needed
MIT © Felix Itzenplitz
Made with ❤️ for the Angular community