I am working on the angular application, When I open my project it is giving me the error like below
ERROR NullInjectorError: R3InjectorError(IndexModule)[InjectionToken NGX_ECHARTS_CONFIG -> InjectionToken NGX_ECHARTS_CONFIG -> InjectionToken NGX_ECHARTS_CONFIG -> InjectionToken NGX_ECHARTS_CONFIG]:
NullInjectorError: No provider for InjectionToken NGX_ECHARTS_CONFIG!
at NullInjector.get (http://localhost:4200/vendor.js:71789:21)
at R3Injector.get (http://localhost:4200/vendor.js:84254:29)
at R3Injector.get (http://localhost:4200/vendor.js:84254:29)
at R3Injector.get (http://localhost:4200/vendor.js:84254:29)
at NgModuleRef$1.get (http://localhost:4200/vendor.js:100306:31)
at R3Injector.get (http://localhost:4200/vendor.js:84254:29)
at NgModuleRef$1.get (http://localhost:4200/vendor.js:100306:31)
at Object.get (http://localhost:4200/vendor.js:97671:29)
at getOrCreateInjectable (http://localhost:4200/vendor.js:75308:31)
at Module.ɵɵdirectiveInject (http://localhost:4200/vendor.js:87509:10)
tried with installation of ngx-echarts
npm install echarts -S
npm install ngx-echarts -S
Still getting the same above error
import NgxEchartsModule
in your app module (or any other proper angular module):
With Dynamic import
import { NgxEchartsModule } from 'ngx-echarts';
@NgModule({
imports: [
...,
NgxEchartsModule.forRoot({
echarts: () => import('echarts')
})
],
})
export class AppModule { }
OR
You can also directly pass the echarts instead which will slow down initial rendering because it will load the whole echarts into your main bundle.
import { NgxEchartsModule } from 'ngx-echarts';
import * as echarts from 'echarts';
@NgModule({
imports: [
NgxEchartsModule.forRoot({
echarts,
}),
],
})
export class AppModule {}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With