简体   繁体   中英

ng2-charts - set default configuration

I'm trying to set default configuration with ng2-charts.

@NgModule({
    ...
    imports: [
        NgChartsModule.forRoot({
            defaults: {
              plugins: {
                tooltip: {
                  enabled: false, // => Type '{ enabled: false; }' is missing the following properties from type 'TooltipOptions<keyof ChartTypeRegistry>': external, position, xAlign, yAlign, and 36 more
                }
              }
            }
        }),
    ]
    ...
}

Problem is, it complains it's missing more than 30 properties on the type TooltipOptions.

I'm obviously not gonna set them all. Is there a default tooltip configuration option I can combine with? I'd like to do this:

tooltip: {
    enabled: false,
    ...tooltipDefaultConfig
}

Same question goes for any option I'd like to override, where can I find default configs?

This works:


NgChartsModule.forRoot({
  defaults: {
    plugins: {
      tooltip: {
        enabled: false
      } as TooltipOptions<keyof ChartTypeRegistry>,
    } as PluginOptionsByType<keyof ChartTypeRegistry>,
  },
}),

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM