Javascript 如何设置highchart时间线中每个点的不同距离?
我看到Highchart的Javascript 如何设置highchart时间线中每个点的不同距离?,javascript,highcharts,timeline,Javascript,Highcharts,Timeline,我看到Highchart的时间线图,它定制了每个点数据标签 我想添加dataLabel选项,为每个点(数据)设置不同的距离。所以我添加了如下代码的选项 但当我使用此代码时,看起来distance选项不起作用。所有数据标签的距离都相同 我怎样才能解决它?我用错什么了吗 Highcharts.chart('container', { chart: { type: 'timeline' }, series: [{ data: [{
时间线图
,它定制了每个点数据标签
我想添加
dataLabel
选项,为每个点(数据)设置不同的距离。所以我添加了如下代码的选项
但当我使用此代码时,看起来distance
选项不起作用。所有数据标签的距离都相同
我怎样才能解决它?我用错什么了吗
Highcharts.chart('container', {
chart: {
type: 'timeline'
},
series: [{
data: [{
date: 'Some date',
label: 'Event label',
description: 'Description of this event.',
dataLabels: {
color: '#78f',
borderColor: 'blue',
backgroundColor: '#444',
connectorWidth: 2,
connectorColor: 'blue',
distance : 80, // I add this option for different distance
style: {
textOutline: 0
}
}
},{
date: 'Another date',
label: 'Last event label',
description: 'Description of third event.',
dataLabels :{
distance : 20
}
}]
}]
});
您可以使用y
属性,而不是为所有数据标签设置的distance
:
series: [{
data: [{
...,
dataLabels: {
y: -50,
...
}
}, {
...,
dataLabels: {
y: 120
}
}]
}]
现场演示:
API参考: