echart折线图多条线

简介: echart折线图多条线
import * as echarts from 'echarts';
var chartDom = document.getElementById('main');
var myChart = echarts.init(chartDom, null, {
  renderer: 'svg'
});
var option;
option = {
  title: {
    text: '打开图片时间对比'
  },
  xAxis: {
    type: 'category',
    data: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
  },
  yAxis: {
    type: 'value'
  },
  series: [
    {
      data: [8.25, 8.61, 8.5, 8.07, 7.66, 7.29, 7.4, 7.56, 7.62, 7.32],
      type: 'line',
      smooth: true,
      label: {
        show: true,
        position: 'bottom',
        textStyle: {
          fontSize: 15
        }
      }
    },
    {
      data: [5.6, 5.51, 6.88, 6.02, 6.25, 5.66, 5.61, 6.08, 5.24, 5.17],
      type: 'line',
      smooth: true,
      label: {
        show: true,
        position: 'bottom',
        textStyle: {
          fontSize: 15
        }
      }
    }
  ]
};
option && myChart.setOption(option);


部分版本:


option = {
    title: {
    text: '打开图片时间对比'
  },
  xAxis: {
    type: 'category',
    data: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
  },
  yAxis: {
    type: 'value'
  },
  series: [
    {
      data: [8.25, 8.61,8.5,8.07,7.66,7.29,7.40,7.56,7.62,7.32],
      type: 'line',
      smooth: true,
      label: {
        show: true,
        position: 'bottom',
        textStyle: {
          fontSize: 15
        }
      }
    },
    {
      data: [5.6,5.51,6.88,6.02,6.25,5.66,5.61,6.08,5.24,5.17],
      type: 'line',
      smooth: true,
      label: {
        show: true,
        position: 'bottom',
        textStyle: {
          fontSize: 15
        }
      }
    }
  ]
};



折线图多条线主要就是


 series: [
    {
      data: [数值1,数值2,...],
      type: 'line',        //线型
      smooth: true,        //平滑曲线
      label: {             //标签(即上标数字)
        show: true,        //显示
        position: 'bottom',
        textStyle: {
          fontSize: 15     //字体大小
        }
      }
    },
//这是另外一个折线(要注意各个花括号的包含层序关系,防止冗余)
    {
      data: [数值3,数值4,...],
      type: 'line',        //线型
      smooth: true,        //平滑曲线
      label: {             //标签(即上标数字)
        show: true,        //显示
        position: 'bottom',
        textStyle: {
          fontSize: 15     //字体大小
        }
    }
  ]


如果不想显示上标数字,去掉label模块就好,即:

 series: [
    {
      data: [数值1,数值2,...],
      type: 'line',        //线型
      smooth: true,        //平滑曲线
    },
//这是另外一个折线(要注意各个花括号的包含层序关系,防止冗余)
    {
      data: [数值3,数值4,...],
      type: 'line',        //线型
      smooth: true,        //平滑曲线
    }
  ]


其实多看echart的文档手册就好↓(结合案列)


Handbook - Apache ECharts

相关文章
|
8月前
ECharts 饼图数据放在饼图内部显示
ECharts 饼图数据放在饼图内部显示
127 0
|
2月前
【统计图】Echarts实现多条折线图渐变堆叠效果
【统计图】Echarts实现多条折线图渐变堆叠效果
|
12月前
|
JavaScript 数据格式 容器
echarts图表-饼图、柱状图、折线图、散点图之间相互切换
echarts图表-饼图、柱状图、折线图、散点图之间相互切换
264 0
echarts设置多条折线不是你想的那样简单
echarts设置多条折线不是你想的那样简单
|
8月前
|
JSON 数据格式
Echarts折线图分段用不同颜色显示
Echarts折线图分段用不同颜色显示
75 0
|
8月前
去掉Echarts饼状图的引导线
去掉Echarts饼状图的引导线
128 0
|
8月前
|
前端开发
【前端统计图】echarts多条折线图和横柱状图实现
【前端统计图】echarts多条折线图和横柱状图实现
70 0
|
8月前
echarts多条折线图和柱状图实现
echarts多条折线图和柱状图实现
51 0
|
8月前
|
JSON 前端开发 数据格式
【前端统计图】echarts实现单条折线图
【前端统计图】echarts实现单条折线图
43 0
|
12月前
|
前端开发
echart折线图堆叠 y轴和实际数据不对应
echart折线图堆叠 y轴和实际数据不对应
114 0