在(highcharts)气泡图上显示百分比值
Display Percentage Values on (highcharts) bubble chart
https://jsfiddle.net/Kondaldurgam/ewng3aqa/
我有气泡大小值。我想用百分比显示值 如何用 percentage.Its 显示值 是否可以显示?
在气泡图上显示百分比值
Highcharts.chart('container', {
chart: {
type: 'bubble',
plotBorderWidth: 0,
zoomType: 'xy'
},
title: {
text: 'Highcharts bubbles with radial gradient fill'
},
xAxis: {
gridLineWidth: 1
},
yAxis: {
startOnTick: false,
endOnTick: false
},
plotOptions: {
bubble: {
dataLabels: {
enabled: true,
x:30
},
}
},
series: [{
data: [
[9, 81, 63],
[98, 5, 89],
[51, 50, 73],
[41, 22, 14],
[58, 24, 20],
[78, 37, 34],
[55, 56, 53],
[18, 45, 70],
[42, 44, 28],
[3, 52, 59],
[31, 18, 97],
[79, 91, 63],
[93, 23, 23],
[44, 83, 22]
],
marker: {
fillColor: {
radialGradient: { cx: 0.4, cy: 0.3, r: 0.7 },
stops: [
[0, 'rgba(255,255,255,0.5)'],
[1, Highcharts.Color(Highcharts.getOptions().colors[0]).setOpacity(0.5).get('rgba')]
]
}
}
}, ]
});
查看其他答案以获得更简单的解决方案。对于更复杂的解决方案,使用 jquery:
setTimeout 用于等待图表加载。
setTimeout(function(){
var objects = $('.highcharts-data-label text tspan');
var text = "";
objects.each(function(){
text = $(this).text();
$(this).text(text + ' %');
});
},500);
你只需要添加格式选项
bubble: {
dataLabels: {
enabled: true,
x:30,
format: "{y}%"
},
}
请参阅 fiddle 此处 https://jsfiddle.net/ewng3aqa/1/
https://jsfiddle.net/Kondaldurgam/ewng3aqa/
我有气泡大小值。我想用百分比显示值 如何用 percentage.Its 显示值 是否可以显示? 在气泡图上显示百分比值
Highcharts.chart('container', {
chart: {
type: 'bubble',
plotBorderWidth: 0,
zoomType: 'xy'
},
title: {
text: 'Highcharts bubbles with radial gradient fill'
},
xAxis: {
gridLineWidth: 1
},
yAxis: {
startOnTick: false,
endOnTick: false
},
plotOptions: {
bubble: {
dataLabels: {
enabled: true,
x:30
},
}
},
series: [{
data: [
[9, 81, 63],
[98, 5, 89],
[51, 50, 73],
[41, 22, 14],
[58, 24, 20],
[78, 37, 34],
[55, 56, 53],
[18, 45, 70],
[42, 44, 28],
[3, 52, 59],
[31, 18, 97],
[79, 91, 63],
[93, 23, 23],
[44, 83, 22]
],
marker: {
fillColor: {
radialGradient: { cx: 0.4, cy: 0.3, r: 0.7 },
stops: [
[0, 'rgba(255,255,255,0.5)'],
[1, Highcharts.Color(Highcharts.getOptions().colors[0]).setOpacity(0.5).get('rgba')]
]
}
}
}, ]
});
查看其他答案以获得更简单的解决方案。对于更复杂的解决方案,使用 jquery:
setTimeout 用于等待图表加载。
setTimeout(function(){
var objects = $('.highcharts-data-label text tspan');
var text = "";
objects.each(function(){
text = $(this).text();
$(this).text(text + ' %');
});
},500);
你只需要添加格式选项
bubble: {
dataLabels: {
enabled: true,
x:30,
format: "{y}%"
},
}
请参阅 fiddle 此处 https://jsfiddle.net/ewng3aqa/1/