Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for chartjs 3 #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

zachary822
Copy link

Update the dist file and use the newer Chart.register instead of Chart.plugin.register.

@Djones4822
Copy link

importing this dist using

<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.5.0/chart.min.js"> </script>
<script src='js/chartjs-plugin-boxselect.js'></script>

yields an error when I release the box:

chartjs-plugin-boxselect.js:57 Uncaught TypeError: Cannot read properties of undefined (reading 'valueOrDefault')
    at doSelect (chartjs-plugin-boxselect.js:57)
    at Object.afterEvent (chartjs-plugin-boxselect.js:208)
    at Q (chart.min.js:13)
    at Fn._notify (chart.min.js:13)
    at Fn.notify (chart.min.js:13)
    at oo.notifyPlugins (chart.min.js:13)
    at oo._eventHandler (chart.min.js:13)
    at n (chart.min.js:13)
    at oo.e (chart.min.js:13)
    at chart.min.js:7

It appears to be a bug in the factory parameter setting, line 4
global.boxselectplugin = factory(global.Chart, global.helpers));

where you need to have

global.boxselectplugin = factory(global.Chart, global.Chart.helpers));

With that change I am able to import and use successfully. I am not familiar enough with rollup or plugin development to assist further, but I hope this is helpful.

@Djones4822
Copy link

I'm also not entirely sure why, but before I could get this working in production nicely with other plugins, I also had to add:

	if (!chart.boxselect) {
		return false;
	}

to the beginning of both afterDraw and beforeTooltipDraw methods

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants