Open dan-ville opened 1 year ago
I'm getting the same issue
Any updates on this?? I'm getting this exact same error.
Any updates on this? I'm getting this exact same error.
Unfortunately the same issue here as well.
I got the same error with the plugin version 2.0.1 and chart.js 4 using Angular. It seems, that this is a timing error. The plugin was/is not ready in chart.
So in the afterDraw function the access on the variable chart.crosshair.enabled failed.
My quick fix is not beautiful, but it helped me and hope some of you guys too:
import { CrosshairPlugin, Interpolate } from 'chartjs-plugin-crosshair';
// Dont use the plugin as it is. Error in afterDraw function
// Chart.register(CrosshairPlugin);
const CustomCrosshairPlugin = function (plugin) {
const originalAfterDraw = plugin.afterDraw;
plugin.afterDraw = function(chart, easing) {
if (chart && chart.crosshair) {
originalAfterDraw.call(this, chart, easing);
}
};
return plugin;
};
Chart.register(CustomCrosshairPlugin(CrosshairPlugin));
The trick is to override this function and make the check here. Should work also, if the plugin will be updated.
The trick is to override this function and make the check here. Should work also, if the plugin will be updated.
worked as a charm.
Thank you
Hi, I'm using this plugin (version 1.2.0) in a Next13 project with Turbo and ChartJS version 4.2.1, I am getting this error when working with Line charts:
This is my component implementation:
This is the entire stack trace: