用饼图组更小的片以提高可读性 [英] Group Smaller Slices in Pie Charts to Improve Readability
本文介绍了用饼图组更小的片以提高可读性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将百分比不超过10%的数据分组到一个名为别人的馅饼中。可能吗?
饼图
系列:[{
类型:'pie',
名称:'浏览器共享',
数据:[
['Firefox',45.0] ,
['IE',26.8],
{
名称:'Chrome',
y:12.8,
切片:true,
selected:true
},
['Safari',8.5],
['Opera',6.2]
]
}]
解决方案
您只需要计算稍微不同的数据。用<<<<< 10%。
类似这样的: c> var data = [
['Firefox',45.0],
['IE',26.8],
{
name:'Chrome',
y: 12.8,
切片:true,
选中:true
},
['Safari',8.5],
['Opera',6.2]
]。
var newData = [];
var other = 0.0;
for(var slice in data){
if(data [slice] [1]< 10){
other + = data [slice] [1];
} else {
newData.push(data [slice]);
}
}
newData.push(['other',other]);
I want to group data thar have under 10% percentage to be grouped to slice of pie named others. Is it possible? Pie-chart
series: [{
type: 'pie',
name: 'Browser share',
data: [
['Firefox', 45.0],
['IE', 26.8],
{
name: 'Chrome',
y: 12.8,
sliced: true,
selected: true
},
['Safari', 8.5],
['Opera', 6.2]
]
}]
解决方案
You just need to calculate slightly different data. Iterate over the entries looking for items with < 10%. Add these to an 'other' category.
Something like this:
var data = [
['Firefox', 45.0],
['IE', 26.8],
{
name: 'Chrome',
y: 12.8,
sliced: true,
selected: true
},
['Safari', 8.5],
['Opera', 6.2]
];
var newData=[];
var other=0.0;
for (var slice in data) {
if (data[slice][1] < 10) {
other += data[slice][1];
} else {
newData.push(data[slice]);
}
}
newData.push(['other',other]);
这篇关于用饼图组更小的片以提高可读性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文