WPIntell

Source evidence

Tooltip Dataset labels missing

M Chart · support · 2024-03-18T13:29:00+00:00

mixedsentiment
highseverity
0.94relevance
9replies
Evidence linked to opportunitycommercial context

Proof Health

Open evidence

Commercial opportunities need traceable source links before they are treated as build-worthy.

5 / 24 rows with source links

20.8% of this page's analysis has direct source links.

0 build-decision rows missing links

0 rows here require auditable proof before promotion.

19 rows with no attached evidence

0 rows have source counts but still need direct links.

Conversation

support
jnaran resolved
Hi there, Thanks for an amazing plugin! I’m not sure if this is the default setting, but whenever I hover over my stacked column chart, the values for the datasets appear in the tooltip, but not the names of the datasets. How do I enable the dataset names so that it correctly displays in the tooltip? For example, this is what i currently displaying in the tooltip when I hover over a column: 29 Jan 27 15 13 5 This is what I’d like to display instead: 29 Jan Reg Adults: 27 Reg Kids: 15 Visitors: 13 Newcomers: 5 Thanks, Jayesh 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. 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 2 years, 1 month ago by methnen . 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.

Comments

9 shown
jnaran 2024-03-19T01:29:00+00:00

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!

methnen 2024-03-23T00:50:00+00:00

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.

methnen 2024-04-02T16:44:00+00:00

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.

jnaran 2024-04-03T03:14:00+00:00

Thanks Jamie, really appreciate your help. Just sent you an email.

methnen 2024-04-16T22:04:00+00:00

Did you see my email reply with a possible fix? This reply was modified 2 years, 1 month ago by methnen .

jnaran 2024-04-17T00:00:00+00:00

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?

methnen 2024-04-17T00:09:00+00:00

Thought that might be the case. I just sent it again, hopefully it gets to you this time. Let me know please either way.

methnen 2024-04-17T00:09:00+00:00

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. 😛

methnen 2024-05-08T20:47:00+00:00

This issue was resolved over email and the fix will be in the next release of M Chart.