简体   繁体   English

高(饼图)图表计算错误

[英]High (Pie) Charts Incorrect Calculation

can someone please help me understand why my pie charts percentage calculation is incorrect? 有人可以帮我了解为什么我的饼图百分比计算不正确吗? See screenshot: 看截图:

在此处输入图片说明

According to my calculation the spend % is supposed to be 24.73% as seen on the RHS. 根据我的计算,RHS上的支出百分比应为24.73%。 The values passed to Highcharts are as follows: - Spend: 204827099.36 - Budget: 828095192.11 传递给Highcharts的值如下:-支出:204827099.36-预算:828095192.11

My calculation is as follows (Spend/Budget) * 100 : (204827099.36/828095192.11)*100=24.73% 我的计算如下(Spend/Budget) * 100(204827099.36/828095192.11)*100=24.73%

Here's how I've specified these values in the highchart: 这是我在highchart中指定这些值的方式:

plotOptions: {
    pie: {
        allowPointSelect: true,
        cursor: 'pointer',
        dataLabels: {
            enabled: true,
            format: '<b>{point.name}</b>: {point.percentage:.2f} %',
            style: {
                color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
            }
        },
        showInLegend: true
    }
},
series: [{
    name: 'Brands',
    colorByPoint: true,
    data: [{
        name: 'Budget',
        color: '#1e80c1',
        y: parseFloat(828095192.11)
    }, {
        name: 'Spend',
        color: '#fdc942',
        y: parseFloat(204827099.36)
    }]
}]

Is there something that I am doing wrong? 我做错了什么吗? Thanks in advance.. 提前致谢..

You are directly dividing one by the other, however you should divide it by total: 您直接将一个除以另一个,但是应将其除以总数:

204827099.36/(828095192.11+204827099.36) =~ 0.1983

The library is correct. 该库是正确的。 I guess you want the blue part to show what is remaining after 204827099.36, in that case you should pass it like this: 我猜您想让蓝色部分显示204827099.36之后剩余的内容,在这种情况下,您应该像这样传递它:

series: [{
    name: 'Brands',
    colorByPoint: true,
    data: [{
        name: 'Budget',
        color: '#1e80c1',
        y: parseFloat(623268092.75)
    }, {
        name: 'Spend',
        color: '#fdc942',
        y: parseFloat(204827099.36)
    }]
}]

Then it will give you the percentage that you want, but is it what you want? 然后,它将为您提供所需的百分比,但这是您想要的吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM