My Highcharts Pie Chart is calculating a percentage incorrectly and I've no idea how/why.
These are the values I am passing to it (Spend vs Budget):
budget: 34319326.40
spent: 10000000.00
The correct percentage is supposed to be: 29.14%
even though my chart display 22.56%
as spent.
As you can see, my system's calculated percentage is correct but the one calculated by Highcharts is lower and incorrect. Below is how I pass the series data the pie chart:
series: [{
name: 'Brands',
colorByPoint: true,
data: [{
name: 'Budget',
color: '#1e80c1',
y: parseFloat( budget )
}, {
name: 'Spend',
color: '#fdc942',
y: parseFloat( spent )
}]
}]
I was suspecting that maybe my parseFloat is affecting the accuracy though if I do the calculation on firebug console I get the correct result:
Does anyone know what could be causing this issue? Thanks in advance
It calculate base on total value
console.log((10000000.00/(34319326.40+10000000.00)*100).toFixed(2))
console.log((34319326.40/(34319326.40+10000000.00)*100).toFixed(2))