1、应用场景
(1)后端返回数据,且对数据不好倒序时(比如时间反序)。
(2)根据页面的按钮,变换X或Y的坐标轴数据。

2、解决方法
在option中添加 inverse:true

option = {
    xAxis: {
        type: 'category',
        data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
        inverse:true
    },
    yAxis: {
        type: 'value'
    },
    series: [{
        data: [820, 932, 901, 934, 1290, 1330, 1320],
        type: 'line'
    }]
};
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.

翻转X坐标数据,inverse:true就加在xAxis中,
相反,翻转Y坐标,就加在yAxis中。
同时加,就是都翻转。