我想创建一个 Highcharts xrange 图表,其中仅显示适合框/范围的数据标签。这可能吗?
目前,标签不会重叠,但在不适合时会显示在框外。
我尝试使用 xrange.dataLabels 选项,例如“allowOverlap”、“clip”、“inside”或“padding”,但它们似乎不是为了执行此/工作而创建的。
示例如下所示:http: //jsfiddle.net/mdomnita/dfLw7j1c/1/
Highcharts.chart('container', {
chart: {
type: 'xrange'
},
title: {
text: 'Highcharts X-range'
},
xAxis: {
type: 'datetime'
},
yAxis: {
title: {
text: ''
},
categories: ['Idea','Prototyping'],
reversed: true
},
series: [{
name: 'Project 1',
data: [{
x: Date.UTC(2014, 10, 21),
x2: Date.UTC(2014, 11, 2),
y: 0
}, {
x: Date.UTC(2014, 11, 10),
x2: Date.UTC(2014, 11, 11),
y: 1
}, {
x: Date.UTC(2014, 11, 11),
x2: Date.UTC(2014, 11, 12),
y: 1
}],
dataLabels: {
enabled: true,
formatter: function () {
return 'This is a label that should only be shown if it fits the box'
},
}
}]
});
谢谢,