将Echarts图X坐标轴与数据一一对应 您所在的位置:网站首页 折线图中左右坐标轴 将Echarts图X坐标轴与数据一一对应

将Echarts图X坐标轴与数据一一对应

2024-07-04 22:24| 来源: 网络整理| 查看: 265

直接上代码:

Axis: { type: 'category', data:["11-05 10:20:00", "11-05 10:21:00", "11-05 10:22:00"], splitLine: { show: false }, axisLine: { show: false }, axisTick: { show: false }, splitArea: { show: false } },

此时Axis里面的data是时间["11-05 10:20:00", "11-05 10:21:00", "11-05 10:22:00"],而我现在的需求是,将我的数据跟时间一一对应。

这时候就要注意在Series中的data不能单放数据了,还要加上时间。

series: [ { data: ["11-05 10:20:00", 14.06], type: 'line', smooth: true, symbolSize: 6, itemStyle: { normal: { color: colorList[i] } } }, { data: ["11-05 10:21:00", 21.82], type: 'line', smooth: true, symbolSize: 6, itemStyle: { normal: { color: colorList[i] } } }, { data: ["11-05 10:22:00", 22.53], type: 'line', smooth: true, symbolSize: 6, itemStyle: { normal: { color: colorList[i] } } }

即,写成这种格式       data:  ["11-05 10:20:00", 14.06]。

这样就可以做到一一对应啦。看看结果图:

 



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有