0
votes

How to display key labels on for example xAxis. Let's say I have time series and would like display segmented label information and make sure certain label would always be shown.

Let's say my data is like ['2015/1/1', '2015/1/2', ..., '2016/12/31']

and I would like my axis to be like 2015 3 15 27 Feb 5 14 26 Mar ... 2015

Is there a way to achieve that in echart's?

1

1 Answers

0
votes

Try use xAxis.axisLabel.formatter to display custom label.

for example:

option = {
    xAxis: {
        type: 'category',
        data: ['2015/1/1', '2015/1/2', '2015/1/3',  '2015/14' ,'2016/12/31'],
        axisLabel: {
            formatter: function (value) {
                return   value.split('/').join('-');
            }
        }
    },
    yAxis: {
        type: 'value'
    },
    series: [{
        data: [820, 932, 901, 934, 1290, 1330, 1320],
        type: 'line',
        smooth: true
    }]
};

enter image description here