Skip to content

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