user10742586
user10742586

Reputation: 5

How to load highcharts annotations module in angular module app.module.ts?

I am trying to import highcharts-annotations in angular 6 typescript module file app.module.ts. I tried the below code but it is showing an error

"Could not find declaration file for module 'highcharts/module/annotations' "

But the annotations.js file resides in the same path and it is showing error in console

"ERROR TypeError: chart.addAnnotation is not a function".

Has someone tried this before?

Code:

import { ChartModule } from 'angular2-highcharts';

import { AnnotationsModule } from 'highcharts/modules/annotations';

import * as Highcharts from 'highcharts';

Upvotes: 1

Views: 1578

Answers (1)

Wojciech Chmiel
Wojciech Chmiel

Reputation: 7372

Try to import the module in that way:

import * as AnnotationsModule from "highcharts/modules/annotations"

And initialize it:

AnnotationsModule(Highcharts);

Or use require:

require('highcharts/modules/exporting')(Highcharts);

Check the demo with highcharts-angular official wrapper which I recommend you.

Demo: https://codesandbox.io/s/329llv6wj1

Upvotes: 1

Related Questions