facioquo/stock-charts

Add `chartjs-plugin-crosshair` after > v1.2.0 released with fixes

Closed this issue · 2 comments

When upgrading to chart.js v3, the chartjs-plugin-crosshair plugin did not work. Subsequent upgrades to the plugin by the author (v1.2.0) did not seem to resolve all issues related to using Angular build with Typescript.

I have not been able to get it to work and suspect it would require substantial effort to workaround issues. Wait for further plugin updates before trying to re-implement.

Error: src/app/chart/chart.service.ts:36:21 - error TS2322: Type '{ title: { font: { family: string; }; display: false; }; legend: { display: false; }; tooltip: { enabled: true; mode: "index"; intersect: false; }; crosshair: any; }' is not assignable to type '_DeepPartialObject<PluginOptionsByType<keyof ChartTypeRegistry>>'.
  Object literal may only specify known properties, and 'crosshair' does not exist in type '_DeepPartialObject<PluginOptionsByType<keyof ChartTypeRegistry>>'.

 options: {
   plugins: {
      ...
      crosshair: {...}
   } }

  node_modules/chart.js/types/index.esm.d.ts:2717:3
    2717   plugins: PluginOptionsByType<TType>;
           ~~~~~~~
    The expected type comes from property 'plugins' which is declared here on type '_DeepPartialObject<CoreChartOptions<keyof ChartTypeRegistry> & ElementChartOptions<keyof ChartTypeRegistry> & PluginChartOptions<...> & DatasetChartOptions<...> & ScaleChartOptions<...>>'

Not getting much support from the author of this plugin to fix anything. It does not work, even after overriding or adding missing typings.