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

helpers.merge is not a function #4

Closed
Techn1x opened this issue Sep 11, 2017 · 4 comments
Closed

helpers.merge is not a function #4

Techn1x opened this issue Sep 11, 2017 · 4 comments

Comments

@Techn1x
Copy link

Techn1x commented Sep 11, 2017

Getting the following error when loading up my charts;

ember-metal.js:3988 TypeError: helpers.merge is not a function
    at configure (chartjs-plugin-datalabels.js:573)
    at Object.afterDatasetUpdate (chartjs-plugin-datalabels.js:581)
    at Object.notify (Chart.js:6937)
    at Chart.updateDataset (Chart.js:4165)
    at Chart.updateDatasets (Chart.js:4140)
    at Chart.update (Chart.js:4087)
    at Chart.construct (Chart.js:3844)
    at new Chart (Chart.js:6340)
    at Class.didInsertElement (ember-chart.js:18)
    at Class.superWrapper [as didInsertElement] (ember-utils.js:423)

This occurs on the following line;
https://github.com/chartjs/chartjs-plugin-datalabels/blob/master/src/plugin.js#L304

I am using Chart.js 2.7.0
capture3

When I step through the code, I can see that helpers is defined, and has lots of helper functions, but is missing merge. It does however have configMerge and scaleMerge which I believe are more specific use cases of the merge function. Should merge perhaps be configMerge??

Looking at the other variables on the line, config == {}, options == (default option object), override == undefined.

@Techn1x
Copy link
Author

Techn1x commented Sep 11, 2017

In case it helps, here's my options

options: {
	maintainAspectRatio: false,	// Set to false for responsive height..... (it's weird)
	responsive: true,
	
	cutoutPercentage: 50,	// Makes this a doughnut graph
	rotation:0.7 * Math.PI,
	circumference:1.6 * Math.PI,
	legend: {
		display: true,
		position: 'bottom'
	},
	plugins: {
		datalabels: {
			backgroundColor: 'black',
			borderColor: 'white',
			borderRadius: 25,
			borderWidth: 2,
			display: true,
			color: 'white',
			font: {
				weight: 'bold'
			},
			anchor: 'start'
		}
	}
}

@simonbrunel
Copy link
Member

@Techn1x it's definitely helpers.merge that needs to be used, which is in 2.7.0 and actually works in the examples. When reading your stacktrace, it seems that your are still using 2.6.0 because Object.notify (Chart.js:6937) is 2.6, not 2.7.

Maybe a cache / environment issue?

@Techn1x
Copy link
Author

Techn1x commented Sep 11, 2017

Thanks, that is good to know and might explain a separate issue I'm having... I'll get back to you when I figure out what's going on.

@Techn1x
Copy link
Author

Techn1x commented Sep 11, 2017

Yep, turns out npm & node_modules was lying to me! Despite all of the evidence saying 2.7.0, my website was using chart.js 2.6.0. Wasn't a caching issue, ended up being a chartjs plugin that was importing chartjs in a way that npm didn't recognise

Datalabels are now appearing, with no errors, thanks!

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

No branches or pull requests

2 participants