如何在海图时间轴中设置每个点的不同距离?

问题描述 投票:0回答:1

我看到Highchart的timeline chart,它自定义了每个点dataLabel。我想添加dataLabel选项为每个点(数据)设置不同的distance。因此,我添加了如下代码所示的选项。

但是当我使用此代码时,distance选项似乎不起作用。 dataLabel's的所有距离都相同。

我该如何解决?我用错了吗?

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
           }
        }]
    }]
});
javascript highcharts timeline
1个回答
0
投票

您可以使用distance属性来代替为所有数据标签设置的y

series: [{
    data: [{
        ...,
        dataLabels: {
            y: -50,
            ...
        }
    }, {
        ...,
        dataLabels: {
            y: 120
        }
    }]
}]

实时演示: http://jsfiddle.net/BlackLabel/femo49gn/

API参考: https://api.highcharts.com/highcharts/series.timeline.dataLabels.y

© www.soinside.com 2019 - 2024. All rights reserved.