emn178 / chartjs-plugin-labels

Plugin for Chart.js to display percentage, value or label in Pie or Doughnut.
MIT License
614 stars 219 forks source link

Fix: parcentage value calculation is fixed so the value is rounded. #98

Open mtskf opened 5 years ago

mtskf commented 5 years ago

The percentage value was calculated by .toFixed method which just cut the decimal values like Math.floor. I updated the logic for the percentage values so it's properly rounded at the specified decimal position by the precision option.

ie: When the value is 56.5556 and the precision is 1: original version: 56.5% updated version: 56.6%

I'd appreciate if you could merge this fix. Cheers:)