echarts-带面积的折线图

简介: echarts-带面积的折线图

测试地址   https://gallery.echartsjs.com/editor.html?c=x6p5SsIEzt


var listN = '高温';
var unit = '°C'; //单位
var timeArray = ["20:00", "20:05", "20:10", "20:15", "20:20", "20:25", "20:30", "20:35", "20:40", "20:45", "20:50", "20:55", "21:00", "21:05", "21:10", "21:15", "21:20", "21:25", "21:30", "21:35", "21:40", "21:45", "21:50", "21:55", "22:00", "22:05", "22:10", "22:15", "22:20", "22:25", "22:30", "22:35", "22:40", "22:45", "22:50", "22:55", "23:00", "23:05", "23:10", "23:15", "23:20", "23:25", "23:30", "23:35", "23:40", "23:45", "23:50", "23:55", "00:00", "00:05", "00:10", "00:15", "00:20", "00:25", "00:30", "00:35", "00:40", "00:45", "00:50", "00:55", "01:00", "01:05", "01:10", "01:15", "01:20", "01:25", "01:30", "01:35", "01:40", "01:45", "01:50", "01:55", "02:00", "02:05", "02:10", "02:15", "02:20", "02:25", "02:30", "02:35", "02:40", "02:45", "02:50", "02:55", "03:00", "03:05", "03:10", "03:15", "03:20", "03:25", "03:30", "03:35", "03:40", "03:45", "03:50", "03:55", "04:00", "04:05", "04:10", "04:15"]; //时间
var dataArray = ["7.2", "7.6", "7.4", "7.1", "6.7", "6.4", "6.3", "6.3", "6.0", "6.0", "6.0", "6.0", "6.0", "6.5", "6.5", "6.5", "6.5", "6.5", "6.5", "6.5", "6.5", "6.5", "6.5", "6.5", "6.5", "6.8", "6.7", "6.7", "6.6", "6.5", "6.5", "6.5", "6.5", "6.5", "6.5", "6.5", "6.4", "6.4", "6.4", "6.4", "6.3", "6.0", "5.8", "5.5", "5.3", "5.1", "5.1", "5.1", "5.1", "5.2", "5.2", "5.2", "5.2", "5.2", "5.2", "5.2", "5.2", "5.2", "5.2", "5.2", "5.2", "5.3", "5.2", "4.9", "4.8", "4.4", "4.0", "3.9", "3.9", "3.9", "3.9", "3.9", "3.9", "3.5", "3.2", "2.9", "2.5", "2.1", "1.9", "1.8", "1.6", "1.5", "1.4", "1.4", "1.4", "1.4", "1.3", "1.1", "1.1", "1.0", "0.8", "0.5", "0.4", "0.4", "0.4", "0.4", "0.4", "0.6", "0.6", "0.6"]; //data
option = {
     backgroundColor: '#000',//背景颜色
     title: {
          left: 'center',
          text: '工作机器人数',
          textStyle: {
              color: '#fff' //标题颜色
          }
     },
    tooltip: {
        trigger: 'axis',
        formatter: ('{b}<br />{a}:{c}'+unit),
    },
    dataZoom: {
        bottom: '0',
         start: 10, //数据窗口范围的起始百分比
         end: 30,  //数据窗口范围的结束百分比
           handleSize: "50%",
        dataBackground: {
            lineStyle: {
                color: '#02C2FF'
            },
            areaStyle: {
                color: 'rgba(2,194,255,1)'
            }
        },
        borderColor: 'rgba(2,194,255,0.2)',
        textStyle: {
            color: '#02C2FF',
        }
    },
    xAxis: [{
        type: 'category',
        boundaryGap: false,
        axisLine: {
            show: true,
            lineStyle: {
                 color: 'rgba(2,194,255,0.2)' //横坐标那一条线的颜色
            },
         },
         axisLabel: {
            textStyle: {
                 color: '#02C2FF', //横坐标  字段名的颜色
                // color:"red",
                fontSize: 12,
                margin:15,
            },
        },
        axisTick: { show: false,},
        data: timeArray
    }],
    yAxis: [{
        type: 'value',
        splitLine: {
            show: true,
            lineStyle: {
                 color: 'rgba(2,194,255,0.2)', //横坐标  分割线颜色
            }
        },
        axisLine: {show: false,},
        axisLabel: {
             margin:6,
            textStyle: {
                color: '#02C2FF'
            },
            formatter: ('{value} '+unit)
        },
        axisTick: { show: false,},
        data:['0','4','8','12','16','20']
    }],
    series: [{
        name: listN,
        type: 'line',
           symbol:'circle',
        symbolSize:4,
        lineStyle: {
            normal: {
                opacity:0
            }
        },
        itemStyle:{
            color:'#FFFFFF'
        },
        areaStyle: { //区域填充样式
            normal: {
                color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                   { offset: 0,  color: 'rgba(2,194,255,1)'}, //上边区域 
                   { offset: 0.7,  color: 'rgba(2,194,255,0.6)'} //下边的区域
                ], false)
            }
        },
        data: dataArray
    }]
};
1425695-20190903192201435-521201562.png



相关文章
|
1月前
echarts 柱状图/折线图x轴坐标间隔
echarts 柱状图/折线图x轴坐标间隔
29 0
|
1月前
|
JavaScript 应用服务中间件 nginx
【报错】nginx部署项目后Echarts折线图无法展示
在Vue3+TS+Arco项目中,打包后使用Nginx部署的Echarts折线图显示异常,报`Cannot read properties of undefined(reading &#39;setOption&#39;)`错误。问题源于在定义div时使用了Vue2的`$refs`语法,导致DOM元素无法正确初始化Echarts。解决方法有两种:1) 不推荐使用`document.getElementById`获取DOM并初始化Echarts;2) 推荐在Vue3中通过`ref`获取DOM,在`onMounted`中使用`echarts.init`并借助`nextTick`异步绘制数据。
|
1月前
【统计图】Echarts实现多条折线图渐变堆叠效果
【统计图】Echarts实现多条折线图渐变堆叠效果
|
1月前
设置echarts的grid、tooltip、柱状图渐变色、折线图渐变色
设置echarts的grid、tooltip、柱状图渐变色、折线图渐变色
|
7月前
|
JSON 数据格式
ECharts折线图渲染json格式数据(格式为对象)
ECharts折线图渲染json格式数据(格式为对象)
68 0
|
7月前
|
JSON 数据格式
ECharts折线图渲染json格式数据(格式为数组)
ECharts折线图渲染json格式数据(格式为数组)
56 0
|
7月前
|
JSON 数据格式
Echarts折线图的折线实线设置成虚线
Echarts折线图的折线实线设置成虚线
110 0
|
7月前
|
JSON 数据格式
Echarts+ajax实现一个简单折线图
Echarts+ajax实现一个简单折线图
38 0
|
7月前
|
JSON 数据格式
Echarts分段折线图图例样式visualMap颜色修改
Echarts分段折线图图例样式visualMap颜色修改
97 1
|
7月前
|
JSON 数据格式
Echarts折线图分段用不同颜色显示
Echarts折线图分段用不同颜色显示
59 0