问题:重叠并且因此不可读dataLabels
在单列堆叠单杠。
用户aus_lacy慷慨帮助我能够执行下面的代码(尤其是在这个答案 ):
HTML
<script src="http://code.highcharts.com/highcharts.js"></script>
<div id="container" style="width:500px; height: 300px"></div>
JS(需要的jQuery)
$(function(){$('#container').highcharts({chart:{backgroundColor:'gray',type: 'bar'},colors:['white'],credits:{enabled:false},title: {text:'Head and neck cancers (HNC)'},
xAxis:{categories:['Estimated 5-year prevalent cancer cases (×1000)'],lineWidth: 0,tickWidth:0,labels: {enabled:false,}},
yAxis:{min:0,title:{text:''},gridLineWidth:0,lineWidth:0,labels:{enabled:false,} }, legend: {enabled:false },
plotOptions: { series: { stacking: 'normal', borderColor: 'black' }, bar: { dataLabels: {enabled: true, distance : -50, formatter: function() { var dlabel = this.series.name + '<br>'; dlabel += Math.round(this.percentage.toFixed(1)*100)/100 + ' %'; return dlabel }, style: { color: 'black', }, }, }, },
series: [{ name: 'Oceania', data: [17]} , { name: 'Africa', data: [94]}, { name: 'Latin America and Carribean', data: [122]} , { name: 'Northern America', data: [181]}, { name: 'Europe', data: [383]},{ name: 'Asia', data: [886] } ] });});
他的回答是完全完美的,但现在我想用一个新的实现,一些酒吧段得到太小揭示的文本dataLabels
(见渲染code
以上)。
也许......或死角?
- 在
distance:-50,
里面dataLabels:{
...}
(内plotOptions:{bar:{
...}
)似乎没有任何工作更长的时间。
我想,如果这个distance
被运行,这可能提供了一个解决方案,因为如果一个如增加了distance: 100,
里面dataLabels:{
... }
中标准的饼图 ,可以清楚地发现其中的差别。 但是饼图显然不是堆积单杠单行?
也许是另一种选择是使用
useHTML
-选项(参见Highcharts API条目),虽然我不能弄清楚如何把事情的工作。我认为,最简单的办法是有一个各
dataLabel
略低于前一个? 任何人都可以做到这一点? 更多或更少的制动器(<br>
的)某些内部dataLabel
的会创造更多的可能性,但我不能做到这一点大气压。...什么更优雅?