Выравнивание Datalables не работает на временной шкале Highchart - PullRequest
0 голосов
/ 02 апреля 2020

Я пытаюсь выровнять данные по левому и правому краю на горизонтальной временной шкале Highchart, используя dataLabels: {align: 'right'} Но это не работает.

Код:

Highcharts.chart('container', {
    chart: {
        type: 'timeline',
        inverted: true
    },
    title: {
        text: 'Timeline of Space Exploration'
    },
    subtitle: {
        text: 'Info source: <a href="https://en.wikipedia.org/wiki/Timeline_of_space_exploration">www.wikipedia.org</a>'
    },
    xAxis: {
        visible: false
    },
    yAxis: {
        visible: false
    },
    plotOptions: {
        series: {
            dataLabels: {
                align: 'right',
                enabled: true
            }
        }
    },
    series: [{
        data: [{
            name: 'First dogs',
            label: '1951: First dogs in space',
            description: '22 July 1951 First dogs in space (Dezik and Tsygan) '
        }, {
            name: 'Sputnik 1',
            label: '1957: First artificial satellite',
            description: '4 October 1957 First artificial satellite. First signals from space.'
        }, {
            name: 'First human spaceflight',
            label: '1961: First human spaceflight (Yuri Gagarin)',
            description: 'First human spaceflight (Yuri Gagarin), and the first human-crewed orbital flight'
        }, {
            name: 'First human on the Moon',
            label: '1969: First human on the Moon',
            description: 'First human on the Moon, and first space launch from a celestial body other than the Earth. First sample return from the Moon'
        }]
    }]
});

Ожидается: для перемещения данных влево и вправо.

1 Ответ

1 голос
/ 02 апреля 2020

Вам необходимо использовать distance свойство:

series: {
  dataLabels: {
    alternate: false,
    distance: -100,
    enabled: true
  }
}

Демонстрационная версия: http://jsfiddle.net/BlackLabel/6m4e8x0y/4942/

Справочник по API: https://api.highcharts.com/highcharts/series.timeline.dataLabels.distance

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...