When using the Chart.js library, I can add multiple doughnuts on my page without a problem.
http://www.chartjs.org/docs/#doughnut-pie-chart
But I cannot find a way to always show the tooltips - not only when hovering the mouse over the doughnut. Does anybody know if this is possible?
You can do this by writing your own plugin which supports ChartJS version > 2.1.5.
Include the following code in your script:
And then just use the following line in the options of any chart on which you want to show all the tooltips available.
Working Fiddle is given below
Working JSFIDDLE here.
In case someone tries to hide some of the segment tooltips; do it in the tooltipTemplate:
for example this code checks for the %value and only displays values higher than 8% to decrease clutter
If you want to display just ONE tooltip, you have to use this code. Here is exaple for first segment.
Function showTooltip only accepts 2 dimensional arrays for first parameter.
I expanded on Kapi's method so when you hover over it you still get to keep the default functionality like color change, and when you hover over a section it will hide the rest. I think it looks better.
I had the same problem today and solved it quite easy by adding the options onAnimationComplte and tooltipevents.
onAnitmationComplete calls the method to show the tooltips like a hover event does. Normally you define the events in tooltipevents to display the tooltips but we need to remove them and pass an empty array.
Note:(http://www.chartjs.org/docs/#doughnut-pie-chart).
Javascript:
HTML:
Example Data:
JSFiddle PIE: http://jsfiddle.net/5gyfykka/
JSFiddle BAR/LINE: http://jsfiddle.net/5gyfykka/14/