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

网络编程 发布日期:2024/9/24 浏览次数:1

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

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

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

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值后

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

 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'}}}
     },
   ]
 };

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

一文看懂荣耀MagicBook Pro 16
荣耀猎人回归!七大亮点看懂不只是轻薄本,更是游戏本的MagicBook Pro 16.
人们对于笔记本电脑有一个固有印象:要么轻薄但性能一般,要么性能强劲但笨重臃肿。然而,今年荣耀新推出的MagicBook Pro 16刷新了人们的认知——发布会上,荣耀宣布猎人游戏本正式回归,称其继承了荣耀 HUNTER 基因,并自信地为其打出“轻薄本,更是游戏本”的口号。
众所周知,寻求轻薄本的用户普遍更看重便携性、外观造型、静谧性和打字办公等用机体验,而寻求游戏本的用户则普遍更看重硬件配置、性能释放等硬核指标。把两个看似难以相干的产品融合到一起,我们不禁对它产生了强烈的好奇:作为代表荣耀猎人游戏本的跨界新物种,它究竟做了哪些平衡以兼顾不同人群的各类需求呢?