Skip to content
Advertisement

How add the sizes of the slices in the pie chart (at the top) in Chart.js?

I am starting to learn the chart.js library.

I drew a pie chart (like “pie”). When you hover over the slices of the diagram, a number appears in the pop-up window that sets the size of the sector.

JavaScript

How can you make this number still displayed at the top, where the sectors are listed (I marked this place with a red circle in the picture)?

enter image description here

I can add the required number to the labels array

JavaScript

But then this number will appear twice in the tooltip

enter image description here

Advertisement

Answer

I found the answer. My project is written in CoffeeScript, but I think it would be more useful for the StackOverflow community to post the code in JS.

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement