angular2-highcharts icon indicating copy to clipboard operation
angular2-highcharts copied to clipboard

Module not found: Error: Can't resolve 'highcharts'

Open AbdurRehman91 opened this issue 7 years ago • 2 comments

Hi,I am using angular 4 and trying to use high charts in angular4 and highchart verison is 0.5.5. But i am facing this issue

Module not found: Error: Can't resolve 'highcharts' Module not found: Error: Can't resolve 'highcharts/modules/exporting' My app.modules.ts file contains the following `import {ChartModule} from 'angular2-highcharts'; import {HighchartsStatic} from 'angular2-highcharts/dist/HighchartsService';

declare var require: any; export function highchartsFactory() { const hc = require('highcharts'); const dd = require('highcharts/modules/exporting'); dd(hc); return hc; //return highcharts; }

@NgModule({

 imports:[
 ChartModule,
//ChartModule.forRoot(require('highcharts')),
],
providers: [
{
    provide: HighchartsStatic,
    useFactory: highchartsFactory
}

],

}

P.S:I have tried all the solutions(related to this issue) being discussed in this repo,but still the issue is not resloved.

thanks

AbdurRehman91 avatar Dec 08 '17 13:12 AbdurRehman91

Below code worked for me: app.module.ts import { ChartModule } from 'angular2-highcharts'; import { HighchartsStatic } from 'angular2-highcharts/dist/HighchartsService'; declare var require: any; export function highchartsFactory() { return require('highcharts'); }

@NgModule({ declarations: [ AppComponent ], imports: [ BrowserModule,ChartModule], providers: [ { provide: HighchartsStatic, useFactory: highchartsFactory } ], bootstrap: [AppComponent] }) export class AppModule { }

Add the below on top of your Polyfills.ts to: import 'zone.js'; import 'reflect-metadata';

abhiyg avatar Dec 12 '17 05:12 abhiyg

@AbdurRehman91 https://github.com/rijine/ngx-highcharts

rijine avatar Dec 14 '17 20:12 rijine