当前位置: 移动技术网 > IT编程>开发语言>JavaScript > 解决echarts的多个折现数据出现坐标和值对不上的问题

解决echarts的多个折现数据出现坐标和值对不上的问题

2019年06月01日  | 移动技术网IT编程  | 我要评论

当出现多个折现数据,echarts可以配置stack值使用堆积值还是单个值

option = {
    nodataloadingoption: {
     text: '暂无数据',
     effect: 'bubble',
     effectoption: {effect: {n: 0}}, textstyle: {fontsize: 24}
    },
    symbollist: ['circle'],
    tooltip: {
     trigger: 'axis', textstyle: {align: 'left'},
     axispointer: {linestyle: {color: '#e3e3e3', width: 1, type: 'solid'},}
    },
    // grid: {x: '60px', x2: '60px', borderwidth: 0},
    legend: {data: ['最大响应时长', '平均响应时长', '最小响应时长']},
    toolbox: {show: true},
    // calculable: true,
    xaxis: [{
      type: 'category',
      boundarygap: false,
      data: ['00:00-02:00', '02:00-04:00', '04:00-06:00', '06:00-08:00', '08:00-10:00', '10:00-12:00'],
      splitline: {linestyle: {width: 0}},
      axislabel: {interval: 0,/*横轴信息全部显示*/  rotate: 20,/*20度角倾斜显示*/}
     }],
    yaxis: [{
      type: 'value',
      axisline: {linestyle: {color: '#333', width: 0, type: 'solid'}},
      splitline: {linestyle: {color: '#e3e3e3', width: 1, type: 'dashed'}},
     }],
    series: [
     {
      name: '最大响应时长',
      smooth: true,
      type: 'line',
      stack: '总量', // 重要的点 这个参数会使用堆积值作为纵坐标的刻量值。
      data:[........],
      itemstyle: {normal: {color: '#d06e17', linestyle: {width: 1, color: '#d06e17'}}}
     },{
      name: '平均响应时长',
      smooth: true,
      type: 'line',
      stack: '总量', // 重要的点 这个参数会使用堆积值作为纵坐标的刻量值。
      data:[........],
      itemstyle: {normal: {color: '#c35ad9', linestyle: {width: 1, color: '#c35ad9'}}}
     },{
      name: '最小响应时长',
      smooth: true,
      type: 'line',
      stack: '总量', // 重要的点 这个参数会使用堆积值作为纵坐标的刻量值。
      data:[........],
      itemstyle: {normal: {color: '#1fd5ce', linestyle: {width: 1, color: '#1fd5ce'}}}
     },
   ]

去掉stack值后

 option3 = {
    nodataloadingoption: {
     text: '暂无数据',
     effect: 'bubble',
     effectoption: {effect: {n: 0}}, textstyle: {fontsize: 24}
    },
    symbollist: ['circle'],
    tooltip: {
     trigger: 'axis', textstyle: {align: 'left'},
     axispointer: {linestyle: {color: '#e3e3e3', width: 1, type: 'solid'},}
    },
    // grid: {x: '60px', x2: '60px', borderwidth: 0},
    legend: {data: ['最大响应时长', '平均响应时长', '最小响应时长']},
    toolbox: {show: true},
    // calculable: true,
    xaxis: [{
      type: 'category',
      boundarygap: false,
      data: ['00:00-02:00', '02:00-04:00', '04:00-06:00', '06:00-08:00', '08:00-10:00', '10:00-12:00'],
      splitline: {linestyle: {width: 0}},
      axislabel: {interval: 0,/*横轴信息全部显示*/  rotate: 20,/*20度角倾斜显示*/}
     }],
    yaxis: [{
      type: 'value',
      axisline: {linestyle: {color: '#333', width: 0, type: 'solid'}},
      splitline: {linestyle: {color: '#e3e3e3', width: 1, type: 'dashed'}},
     }],
    series: [
     {
      name: '最大响应时长',
      smooth: true,
      type: 'line',
      // stack: '总量', // 去除stack这个参数
      itemstyle: {normal: {color: '#d06e17', linestyle: {width: 1, color: '#d06e17'}}}
     },{
      name: '平均响应时长',
      smooth: true,
      type: 'line',
      // stack: '总量', // 去除stack这个参数
      itemstyle: {normal: {color: '#c35ad9', linestyle: {width: 1, color: '#c35ad9'}}}
     },{
      name: '最小响应时长',
      smooth: true,
      type: 'line',
      // stack: '总量', // 去除stack这个参数
      itemstyle: {normal: {color: '#1fd5ce', linestyle: {width: 1, color: '#1fd5ce'}}}
     },
   ]
 };

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网