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

How to ensure hover tooltip shows the same value as the one displayed on the chart (provided by formatter) #423

Open
axsaucedo opened this issue Sep 29, 2024 · 0 comments

Comments

@axsaucedo
Copy link

If a formatter is provided, this has effect on the labels that appear on the chart directly, but it seems not on the tooltip labels. How can I make sure that the tooltips also show the correct label? Is this a feature of datalabels? Or would the expectation be that I have to also override the tooltip formatter directly?

As an example, I have a formatter function that changes the labels to %:

                    formatter: (value, ctx) => {
						let sum = 0;
						let dataArr = ctx.chart.data.datasets[0].data;
						dataArr.map(data => {
							sum += data;
						});
						let percentage = (value*100 / sum).toFixed(2)+"%";
						return percentage;
					},

I would like for this same label to appear on the tooltip hover as well, but it seems it only applies to the chart as mentioned.

Let me know if you need any further details. thank you.

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

No branches or pull requests

1 participant