gpt4 book ai didi

jQuery - 系列之外的 HighCharts 标签(条形图)

转载 作者:行者123 更新时间:2023-12-01 01:00:55 25 4
gpt4 key购买 nike

$(function () {
$('#container').highcharts({
chart: {
type: 'bar',
backgroundColor: null,
width: 360
},
title: {
text: null,
style: {
display: 'none'
}
},
subtitle: {
text: null,
style: {
display: 'none'
}
},
credits: {
enabled: false
},
exporting: {
enabled: false
},
xAxis: {
categories: ['Cat 1', 'Cat 2', 'Cat 3', 'Cat 4', 'Cat 5', 'Cat 6', 'Cat 7', 'Cat 8', 'Cat 9', 'Cat 10'],
title: {
text: null
}
},
yAxis: {
min: 0,
max: 10,
gridLineWidth: 0,
minorGridLineWidth: 0,
title: {
text: null
},
labels: {
enabled: false
}
},
tooltip: {
enabled: false
},
plotOptions: {
bar: {
dataLabels: {
enabled: true
}
},
series: {
dataLabels: {
crop: false,
enabled: true,
y: -2,
inside: false
}
}
},
series: [{
showInLegend: false,
name: '',
color: '#CCC',
data: [1, 2, 3, 9.4, 5, 6, 8, 9, 9, 9.5]

}]
});
});

jsfiddle:http://jsfiddle.net/uNrW2/1/

我似乎无法让系列数据的标签始终出现在栏的右侧。我已经浏览了所有 API,但似乎找不到阻止文本移动到栏中的选项。

有人知道为什么会发生这种情况吗?非常感谢您的宝贵时间!

最佳答案

您错过了 API 中名为 plotOptions.series.dataLabels.overflow 的一个选项 ( API ):

overflow: String

How to handle data labels that flow outside the plot area. The default is justify, which aligns them inside the plot area. For columns and bars, this means it will be moved inside the bar. To display data labels outside the plot area, set crop to false and overflow to "none". Defaults to justify.

换句话说,您需要将裁剪和溢出结合起来,如下所示( updated JSFiddle ):

plotOptions: {
series: {
dataLabels: {
enabled: true,
crop: false,
overflow: 'none'
}
}
}

关于jQuery - 系列之外的 HighCharts 标签(条形图),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24845360/

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