Chart.js icon indicating copy to clipboard operation
Chart.js copied to clipboard

fix: same-looking tooltips on multiseries charts

Open dangreen opened this issue 1 year ago • 2 comments

https://github.com/chartjs/Chart.js/issues/9771

  • Now, if tooltip callback returns undefined, then will be used default callback.
  • PolarArea and Doughnut charts with multiple series shows tooltips same as other charts.

dangreen avatar Aug 02 '22 20:08 dangreen

@kurkle Hi. Scatter and Bubble charts don't use data.labels, so should their tooltips also look like on rest multiseries charts?

dangreen avatar Aug 02 '22 20:08 dangreen

I think its better to always show the title with the label of the dataset, not only if there is more than 1 dataset, will give a more consistent and clear look. Same goes for scatter you could use the dataset label in that case

LeeLenaleee avatar Aug 02 '22 21:08 LeeLenaleee

Changes also need to be reflected in the migration guide: https://github.com/chartjs/Chart.js/blob/master/docs/migration/v4-migration.md

LeeLenaleee avatar Aug 05 '22 08:08 LeeLenaleee

On an addition on the reaction I left on @kurkle comment, maby you can delete the labels array from the bubble and scatter samples so they dont show a wrong tooltip title.

image

LeeLenaleee avatar Aug 05 '22 12:08 LeeLenaleee

@LeeLenaleee done

dangreen avatar Aug 07 '22 12:08 dangreen

@kurkle @LeeLenaleee @etimberg Hi guys. Review please 🙏

dangreen avatar Aug 15 '22 08:08 dangreen

LGTM

I believe @kurkle is on vacation so his reviews might be delayed

That was true, but I'm back!

kurkle avatar Aug 18 '22 05:08 kurkle

What if we want to customize the tooltip on the doughnut charts (for example) adding a % calculation but not on every other chart type? How can we achieve that now? @dangreen

Sergiobop avatar Dec 19 '22 12:12 Sergiobop

You can still override the callbacks by configuring it in the options for those charts or in the defaults for that controller

LeeLenaleee avatar Dec 19 '22 12:12 LeeLenaleee

Thanks @LeeLenaleee , maybe we should add this info to the migration guide from 3.x

Sergiobop avatar Dec 19 '22 12:12 Sergiobop

But this did not change between v3 and v4

LeeLenaleee avatar Dec 19 '22 15:12 LeeLenaleee

@LeeLenaleee It's related to this line in the migration guide... right?

https://www.chartjs.org/docs/latest/migration/v4-migration.html

Charts don't override the default tooltip callbacks, so all chart types have the same-looking tooltips.

Sergiobop avatar Dec 19 '22 15:12 Sergiobop

No, that line is about the overrides we did in the code, not about what the user specified.

So in our controllers we overrode those functions but as user you could always override them again and you still can

LeeLenaleee avatar Dec 19 '22 15:12 LeeLenaleee

Could this be related? I'm having issues with labels on bubble charts https://github.com/chartjs/Chart.js/issues/11023

shanecranor avatar Dec 29 '22 15:12 shanecranor