gevgeny / angular2-highcharts

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

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

Open AbdurRehman91 opened 6 years ago

AbdurRehman91 commented 6 years ago

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

abhiyg commented 6 years ago

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';

rijine commented 6 years ago

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