angular-highcharts: TypeError: chartModule is not a function
Hi.
I have a problem using angular-highcharts-stockchart.
I paste example code in my code.
But it occurs an error.
in Chrome console :
TypeError: chartModule is not a function
at eval (angular-highcharts.es5.js:245)
at Array.forEach (<anonymous>)
at ChartService.initModules (angular-highcharts.es5.js:244)
at new ChartModule (angular-highcharts.es5.js:274)
at _createClass (core.js:10915)
at _createProviderInstance$1 (core.js:10889)
at initNgModule (core.js:10842)
at new NgModuleRef_ (core.js:12096)
at createNgModuleRef (core.js:12086)
at Object.debugCreateNgModuleRef [as createNgModuleRef] (core.js:14430)
Below that is my code snippet.
app.module.ts :
...
import {ChartModule, HIGHCHARTS_MODULES} from 'angular-highcharts';
import highstock from 'highcharts/modules/stock.src';
import exporting from 'highcharts/modules/exporting.src';
export function highchartsModules() {
// apply Highstock Modules to this array
return [highstock, exporting];
}
...
@NgModule({
declarations: [
AppComponent,
SigninComponent,
StrategyListComponent,
StrategyDetailComponent,
StrategyComponent
],
imports: [
...
],
providers: [
...
{provide: HIGHCHARTS_MODULES, useFactory: highchartsModules}
],
bootstrap: [AppComponent]
})
export class AppModule {
}
package.json :
...
"@angular/cdk": "^5.0.2",
"@angular/common": "^5.0.0",
"@angular/compiler": "^5.0.0",
"@angular/core": "^5.0.0",
"@angular/forms": "^5.0.0",
"@angular/http": "^5.0.0",
"@angular/material": "^5.0.2",
"@angular/platform-browser": "^5.0.0",
"@angular/platform-browser-dynamic": "^5.0.0",
"@angular/router": "^5.0.0",
"angular-highcharts": "^5.2.0",
"core-js": "^2.4.1",
"highcharts": "^6.0.4",
...
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 48 (11 by maintainers)
@joeykruger @ubirajr The workaround (as mentioned in https://github.com/angular/angular-cli/issues/9058#issuecomment-355021360) is to force the default import for your chart module imports. So do
instead of
for all your chart modules.
@attilacsanyi Tried providers: [ {provide: HIGHCHARTS_MODULES, useFactory: () => [drilldown] }], Its working 😃. Appreciate your help 👍 Thanks.
Dear @superkick I just upgraded to the latest cli (1.7.1) and angular (5.2.6) and the custom
HighchartsModule
still working fine for me:I hope this helps 😉
Thanks @cebor for the update thats really a great news!
BTW, I use this code for more than a month with
Source from angularplaybook of Justin Schwartzenberger who is a product manager and educator at Nrwl.io.
--prod
and working well. Proof:@gubenkovalik try to press on the following button in this issue:
Fuck this shit, how to stop receiving this fucking excrements?
пн, 6 авг. 2018 г., 8:51 renukaamujuru notifications@github.com:
Issue is fixed with
@angular/cli@6.0.0
.@manhar-developer this should work:
import * as drilldown from 'highcharts/modules/drilldown.src.js';
Let me know your case 😉
Hmmm it seems there is issue with the module itself as Angular throws this error:
error TS7016: Could not find a declaration file for module 'highcharts/modules/drilldown.src.js'.
I came across this issue while creating a ‘solidgauge’ chart. To solve it I’ve created a separate module (even though it doesn’t need to be, it’s just cleaner) and called it in my page module :
How to import the more module was the missing link 😃
hey @attilacsanyi,
many thanks for your help!
i can confirm this approach is working correctly for me.
@cebor - excellent news! keep up the great work 👍
@gubenkovalik This https://github.com/cebor/angular-highcharts/issues/112#issuecomment-364705934
@moepkid you don’t have to force the import for
ChartModule
.@filipesilva posted temporary workaround to fix this issue: https://github.com/angular/angular-cli/issues/9058#issuecomment-355021360
I created an issue: https://github.com/angular/angular-cli/issues/9058
Hey all,
--prod
build should work even with ng-cli1.6.3
.Don’t know why normal build is failing, i will let you hear if i find it out.