gevgeny / angular2-highcharts

:bar_chart: :chart_with_upwards_trend: Highcharts for your Angular project
MIT License
381 stars 113 forks source link

how can I import the highcharts-more.js in to app.module.ts #228

Closed tungphien closed 6 years ago

tungphien commented 6 years ago

Hi @gevgeny , all Here is my app.module.ts:

declare var require: any; export function highchartsFactory() { return require('highcharts'); } @NgModule({ declarations: [ AppComponent, StackedChartCommit, StackedChartBug, HeatMapChart ], imports: [ BrowserModule, ChartModule ], providers: [{ provide: HighchartsStatic, useFactory: highchartsFactory },], bootstrap: [AppComponent] })

The Heat Map chart is show error: Highcharts Error #17 The requested series type does not exist This error happens when you are setting chart.type or series.type to a series type that isn't defined in Highcharts. A typical reason may be that your are missing the extension file where the series type is defined, for example in order to run an arearange series you need to load the highcharts-more.js file.

Please help me to correct it, I'm a fresher angular :( Thanks so much

tungphien commented 6 years ago

Fixed: export function highchartsFactory() { var Highcharts = require('highcharts'); var Heatmap = require('highcharts/modules/heatmap'); Heatmap(Highcharts); return Highcharts; }

ericuldall commented 6 years ago

For anyone else that comes across this issue and doesn't have access to require, the following worked for me:

import * as highcharts from 'highcharts';
import * as highchartsStock from 'highcharts/modules/stock';
highchartsStock(highcharts);

Then just include ChartModule.forRoot(highcharts) in your imports.

rkdhanyakula commented 5 years ago

Its worked for me too.

import {chart} from 'highcharts';
import * as Highcharts from 'highcharts';
import * as HighchartsMore from 'highcharts-more';
HighchartsMore(Highcharts);
lorrainelv commented 5 years ago

Its worked for me too.

import {chart} from 'highcharts';
import * as Highcharts from 'highcharts';
import * as HighchartsMore from 'highcharts-more';
HighchartsMore(Highcharts);

it worked for me !

binarycat0 commented 5 years ago

Its worked for me too.

import {chart} from 'highcharts';
import * as Highcharts from 'highcharts';
import * as HighchartsMore from 'highcharts-more';
HighchartsMore(Highcharts);

or like this

import Highcharts from 'highcharts'
import HighchartsReact from 'highcharts-react-official'
import * as HighchartsMore from 'highcharts/highcharts-more'

//magic
HighchartsMore(Highcharts);
lorrainelv commented 5 years ago

Thanks a lot.

arakhmatulin notifications@github.com 于2018年12月30日周日 上午6:10写道:

Its worked for me too.

import {chart} from 'highcharts'; import as Highcharts from 'highcharts'; import as HighchartsMore from 'highcharts-more'; HighchartsMore(Highcharts);

or like this

import Highcharts from 'highcharts' import HighchartsReact from 'highcharts-react-official' import * as HighchartsMore from 'highcharts/highcharts-more'

//magic HighchartsMore(Highcharts);

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/gevgeny/angular2-highcharts/issues/228#issuecomment-450523744, or mute the thread https://github.com/notifications/unsubscribe-auth/AqZlkkSkgDXHLsdGYhx_1zalhTqaG5XRks5u9-hngaJpZM4PUdK6 .