gpt4 book ai didi

css - 如何在组列高位图上显示多数据标签

转载 作者:太空宇宙 更新时间:2023-11-04 10:00:19 25 4
gpt4 key购买 nike

我有想要在列上显示的数据,如下所示:

enter image description here

我试过了 this code但它不起作用。我该怎么做?

HTML:

<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>

<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>

Javascript:

$(function () {
$('#container').highcharts({
chart: {
type: 'column'
},
title: {
text: 'Column chart'
},
xAxis: {
categories: ['Apples', 'Oranges', 'Pears']
},
yAxis: {
min: 0,
title: {
text: 'Total fruit consumption'
},
stackLabels: {
enabled: true,
style: {
fontWeight: 'bold',
color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
}
}
},
legend: {
align: 'right',
x: -70,
verticalAlign: 'top',
y: 20,
floating: true,
backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || 'white',
borderColor: '#CCC',
borderWidth: 1,
shadow: false
},
tooltip: {
formatter: function() {
var allSeries = this.series.chart.series;
var totalAmount = 0;
for(var s in allSeries) { totalAmount += allSeries[s].points[this.point.x].Amount; }

return '<b>'+ this.x +'</b><br/>'+
this.series.name +': '+ this.y + ' (<b>$ ' + this.point.Amount +') <br/>'+
'Total: '+ this.point.stackTotal + ' (<b>$ ' + totalAmount +')';
}
},
plotOptions: {
column: {
dataLabels: {
enabled: true,
color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white',
style: {
textShadow: '0 0 3px black, 0 0 3px black'
},
formatter: function() {
return this.point.Amount + '%'
},

}
}
},
series: [{
name: 'John',
data: [{y: 5, Amount: 100}, {y: 3, Amount: 60}, {y: 4, Amount: 80}]
}, {
name: 'Joe',
data: [{y: 3, Amount: 60}, {y: 4, Amount: 80}, {y: 4, Amount: 80}]
}]
});
});

最佳答案

看看这个 Fiddle

    dataLabels: {
enabled: true,
useHTML: true,
color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white',
style: {
textShadow: '0 0 3px black, 0 0 3px black'
},
formatter: function() {
var pointHeight = this.point.shapeArgs.height + 20;
return '<div class="datalabel" style="position: relative; top: 0px">' + this.point.Amount + '%' + '</div><div class="datalabelInside" style="text-shadow:none;color:#000;position: absolute; top:' + pointHeight / 2 + 'px">' + this.y + '</div>';
}

}

关于css - 如何在组列高位图上显示多数据标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38390017/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com