LoginSignup
0
0

More than 5 years have passed since last update.

angular ChartModule でハマったこと

Posted at

ハマったこと

-ng serveでエラーが出ないのに、AoTビルド(ng build --aot)だとエラーになる

問題コード

@NgModule({
  imports: [
    ChartModule.forRoot(
      require('highcharts'),
      require('highcharts/highcharts-3d'),
      require('highcharts/highcharts-more')
    )
  ]
})
export class AppModule {
}

修正内容

export function highchartsFactory() {
  const chart = require('highcharts');
  const d3 = require('highcharts/highcharts-3d');
  const more = require('highcharts/highcharts-more');
  d3(chart);
  more(chart);

  return chart;
}

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

感想

  • よくわからんかったが、解決した。。。。難しい。。。。
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0