xieziyu / ngx-echarts

An angular (ver >= 2.x) directive for ECharts (ver >= 3.x)
https://xieziyu.github.io/ngx-echarts/
MIT License
1.11k stars 197 forks source link

Charts are not rendered after building(Blank divs) #237

Closed adisreyaj closed 4 years ago

adisreyaj commented 4 years ago

When serving the application the charts are rendered properly without any issues. But when production build is done (`ng build --prod) and we run the application the charts are not being rendered all the divs are just empty.

Configuration:

When I try building without prod flag, the charts are working fine. I suppose it has do something with the AOT compilation.

xieziyu commented 4 years ago

@adisreyaj Maybe you can try this work-around:

import { init } from 'echarts';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    NgxEchartsModule.forRoot({
      echarts: {
        init,
      },
    })
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
adisreyaj commented 4 years ago

This actually worked. So basically it has something to do with the module resolution when using the import * as echarts from 'echarts' style...right?

lundmikkel commented 4 years ago

I don't think this issue should have been closed. The workaround is not a proper solution, it's a ... workaround.