Thread Starter
jnaran
(@jnaran)
Just to follow up on this, I can fix the tooltip labels in the browser console using the code below:
m_chart_chartjs_3889_1.chart_args.options.plugins.tooltip.callbacks.label = function(context) {
var label = context.dataset.label || '';
if (label) {
label += ': ';
}
if (context.parsed.y !== null) {
label += context.parsed.y;
}
return label;
}
But how do I modify “m_chart_chartjs_3889_1” before it has been created? For more context, I can add a sum at the bottom of the tooltip using the chart defaults:
Chart.defaults.plugins.tooltip.callbacks.afterBody = (ttItem) => (Sum: ${ttItem.reduce((acc, val) => (acc + val.raw), 0)});
But when I try to modify the default label function, it reverts to a different function after the chart loads. This is what I want it to be:
Chart.defaults.plugins.tooltip.callbacks.label = function(context) {
var label = context.dataset.label || '';
if (label) {
label += ': ';
}
if (context.parsed.y !== null) {
label += context.parsed.y;
}
return label;
}
This is what it loads as when I access it via the console:
>m_chart_chartjs_3889_1.chart_args.options.plugins.tooltip.callbacks.label
< a=>m_chart_chartjs_helpers.chart_tooltip_label(a,r,t,e,_)
I think it is getting overwritten at some point. Any help would be greatly appreciated!
I think this is a bug on my end. Probably a result of the other fix. I need to make sure I’m testing for multiple situations I think.
I’ll take a look at this soon. Because yes, the plugin itself plugs into the char tooltip callback so I suspect my callback is overwriting your callback.
Jayesh,
Sorry for the delay on this. Life has been something else the last month.
I’m sitting down to work on this and I’m realizing that I might need to se your data set and your settings for the chart in question in order to properly duplicate the issue.
Would you be willing to pass that all my way?
jamie AT methnen.com
Is my email address.
Also please post here when you send it so I know to look for your email.
Thread Starter
jnaran
(@jnaran)
Thanks Jamie, really appreciate your help. Just sent you an email.
Did you see my email reply with a possible fix?
-
This reply was modified 1 year, 11 months ago by
methnen.
Thread Starter
jnaran
(@jnaran)
No I didn’t see it for some reason – there was nothing in my spam either. Not sure what happened there. Did you get my email with all my data?
Thought that might be the case. I just sent it again, hopefully it gets to you this time. Let me know please either way.
OK, your server is refusing it, even with it zipped, probably because it’s got some JS code in it. I’ll put that somewhere else and then try again. 😛
This issue was resolved over email and the fix will be in the next release of M Chart.