Skip to content

折线图两条或两条以上x轴(含有不连续时间轴数据),series方式展示时间不能排序 #14483

@Assur

Description

@Assur

echarts版本是5.0.0,我是用series方式显示时间轴的,但是series方式展示时间不能排序,时间小的反而在后面展示了(即,2020-10-9 00:00:00展示在2020-10-9 00:00:02的后面了),我想要让两个折线按照时间来排序如何做?即2020-10-9 00:00:00展示在2020-10-9 00:00:02的前面这种时间升序格式
var dataTemperature =
[
['2020-10-9 00:00:00', 11], ['2020-10-9 15:00:01', 29], ['2020-10-9 15:00:08', 6]
];
var dataTemperatureB =
[
['2020-10-9 00:00:02', 14], ['2020-10-9 15:00:04', 35], ['2020-10-9 15:00:12', 8]
];

        var myChart = echarts.init(document.getElementById('trendChart'));
        var option = {
            tooltip: {
                trigger: 'axis',
                position: function (pt) {
                    return [pt[0], '10%'];
                }
            },
            backgroundColor: '#ececf2',
            //title: {
            //    left: 'center',
            //    text: '大数据量面积图',
            //},
            toolbox: {
                feature: {
                    dataZoom: {
                        yAxisIndex: 'none'
                    },
                    restore: {},
                    saveAsImage: {}
                }
            },
            legend: {
                data: ['温度'],
                x: 'left'
            },
            xAxis: {
                // 根据x轴数据决定type类型
                type: 'time',
                boundaryGap: false
                // 注: x轴不指定data,自动会从series取
                //data: []
            },
            yAxis: {
                type: 'value',
                boundaryGap: [0, '10%']
            },
            dataZoom: [{
                type: 'inside',
                start: 0,
                end: 10
            }, {
                start: 0,
                end: 10,
                handleIcon: 'M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4v1.3h1.3v-1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z',
                handleSize: '80%',
                handleStyle: {
                    color: '#fff',
                    shadowBlur: 3,
                    shadowColor: 'rgba(0, 0, 0, 0.6)',
                    shadowOffsetX: 2,
                    shadowOffsetY: 2
                }
            }],
            series: [
                {
                    name: 'A相电流',
                    type: 'line',
                    smooth: true,
                    //symbol: 'none',
                    //sampling: 'average',
                    //itemStyle: {
                    //    color: 'rgb(300,100,100)'
                    //},
                    data: dataTemperature,
                    connectNulls: false
                },
                {
                    name: 'B相电流',
                    type: 'line',
                    smooth: true,
                    //symbol: 'none',
                    //sampling: 'average',
                    //itemStyle: {
                    //    color: 'rgb(300,100,100)'
                    //},
                    data: dataTemperatureB,
                    connectNulls: false
                }
            ]
        };

        myChart.setOption(option);

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalidThis issue was not created using the issue template.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions