水情监测统计

描述:当前是关于Echarts图表中的 折线图 示例。
 
            Date.prototype.Format = function (fmt) {
  let o = {
    'M+': this.getMonth() + 1, //月份
    'd+': this.getDate(), //日
    'h+': this.getHours(), //小时
    'm+': this.getMinutes(), //分
    's+': this.getSeconds(), //秒
    'q+': Math.floor((this.getMonth() + 3) / 3), //季度
    'S': this.getMilliseconds() //毫秒
  }
  if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length))
  for (let k in o)
    if (new RegExp('(' + k + ')').test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
  return fmt
}

const colorList = ["#9E87FF", '#73DDFF', '#fe9a8b', '#F56948', '#9E87FF']

option = {
    backgroundColor: '#fff',
    title: {
        text: '',
        textStyle: {
            fontSize: 12,
            fontWeight: 400
        },
        left: 'center',
        top: '5%'
    },
    legend: {
        icon: 'line',
        top: '5%',
        align:'auto',
        itemWidth: 22,
        itemGap: 20,
        textStyle: {
            color: '#556677'
        }
    },
    tooltip: {
        trigger: 'axis',
        axisPointer: {
            label: {
                show: true,
                backgroundColor: '#fff',
                color: '#556677',
                borderColor: 'rgba(0,0,0,0)',
                shadowColor: 'rgba(0,0,0,0)',
                shadowOffsetY: 0
            },
            lineStyle: {
                width: 0
            }
        },
        backgroundColor: '#fff',
        textStyle: {
            color: '#5c6c7c'
        },
        padding: [10, 10],
        extraCssText: 'box-shadow: 1px 0 2px 0 rgba(163,163,163,0.5)'
    },
    grid: {
        top: '15%'
    },
    xAxis: [{
        type: 'category',
        data: ["2020-08-18 00:00", "2020-08-18 01:00", "2020-08-18 02:00", "2020-08-18 03:00", "2020-08-18 04:00", "2020-08-18 05:00", "2020-08-18 06:00", "2020-08-18 07:00", "2020-08-18 08:00", "2020-08-18 09:00", "2020-08-18 10:00", "2020-08-18 11:00", "2020-08-18 12:00", "2020-08-18 13:00", "2020-08-18 14:00", "2020-08-18 15:00", "2020-08-18 16:00", "2020-08-18 17:00", "2020-08-18 18:00", "2020-08-18 19:00", "2020-08-18 20:00", "2020-08-18 21:00", "2020-08-18 22:00", "2020-08-18 23:00", "2020-08-19 00:00", "2020-08-19 01:00", "2020-08-19 02:00", "2020-08-19 03:00", "2020-08-19 04:00", "2020-08-19 05:00", "2020-08-19 06:00", "2020-08-19 07:00", "2020-08-19 08:00", "2020-08-19 09:00", "2020-08-19 10:00", "2020-08-19 11:00", "2020-08-19 12:00", "2020-08-19 13:00", "2020-08-19 14:00", "2020-08-19 15:00", "2020-08-19 16:00", "2020-08-19 17:00", "2020-08-19 18:00", "2020-08-19 19:00", "2020-08-19 20:00", "2020-08-19 21:00", "2020-08-19 22:00", "2020-08-19 23:00", "2020-08-20 00:00", "2020-08-20 01:00", "2020-08-20 02:00", "2020-08-20 03:00", "2020-08-20 04:00", "2020-08-20 05:00", "2020-08-20 06:00", "2020-08-20 07:00", "2020-08-20 08:00", "2020-08-20 09:00", "2020-08-20 10:00", "2020-08-20 11:00", "2020-08-20 12:00", "2020-08-20 13:00", "2020-08-20 14:00", "2020-08-20 15:00", "2020-08-20 16:00", "2020-08-20 17:00", "2020-08-20 18:00", "2020-08-20 19:00", "2020-08-20 20:00", "2020-08-20 21:00", "2020-08-20 22:00", "2020-08-20 23:00", "2020-08-21 00:00", "2020-08-21 01:00", "2020-08-21 02:00", "2020-08-21 03:00", "2020-08-21 04:00", "2020-08-21 05:00", "2020-08-21 06:00", "2020-08-21 07:00", "2020-08-21 08:00", "2020-08-21 09:00", "2020-08-21 10:00", "2020-08-21 11:00", "2020-08-21 12:00", "2020-08-21 13:00", "2020-08-21 14:00", "2020-08-21 15:00", "2020-08-21 16:00", "2020-08-21 17:00", "2020-08-21 18:00", "2020-08-21 19:00", "2020-08-21 20:00", "2020-08-21 21:00", "2020-08-21 22:00", "2020-08-21 23:00", "2020-08-22 00:00", "2020-08-22 01:00", "2020-08-22 02:00", "2020-08-22 03:00", "2020-08-22 04:00", "2020-08-22 05:00", "2020-08-22 06:00", "2020-08-22 07:00", "2020-08-22 08:00", "2020-08-22 09:00", "2020-08-22 10:00", "2020-08-22 11:00", "2020-08-22 12:00", "2020-08-22 13:00", "2020-08-22 14:00", "2020-08-22 15:00", "2020-08-22 16:00", "2020-08-22 17:00", "2020-08-22 18:00", "2020-08-22 19:00", "2020-08-22 20:00", "2020-08-22 21:00", "2020-08-22 22:00", "2020-08-22 23:00", "2020-08-23 00:00", "2020-08-23 01:00", "2020-08-23 02:00", "2020-08-23 03:00", "2020-08-23 04:00", "2020-08-23 05:00", "2020-08-23 06:00", "2020-08-23 07:00", "2020-08-23 08:00", "2020-08-23 09:00", "2020-08-23 10:00", "2020-08-23 11:00", "2020-08-23 12:00", "2020-08-23 13:00", "2020-08-23 14:00", "2020-08-23 15:00", "2020-08-23 16:00", "2020-08-23 17:00", "2020-08-23 18:00", "2020-08-23 19:00", "2020-08-23 20:00", "2020-08-23 21:00", "2020-08-23 22:00", "2020-08-23 23:00", "2020-08-24 00:00", "2020-08-24 01:00", "2020-08-24 02:00", "2020-08-24 03:00", "2020-08-24 04:00", "2020-08-24 05:00", "2020-08-24 06:00", "2020-08-24 07:00", "2020-08-24 08:00", "2020-08-24 09:00"],
        axisLine: {
            lineStyle: {
                color: '#DCE2E8'
            }
        },
        axisTick: {
            show: false
        },
        axisLabel: {
            // formatter(value,index){
            //     var dt = new Date(value);
            //     return dt.Format("yyyy-MM-dd")
            // },
            // interval: 0,
            textStyle: {
                color: '#556677'
            },
            // align:'left',
            // 默认x轴字体大小
            fontSize: 12,
            // margin:文字到x轴的距离
            margin: 22
        },
        axisPointer: {
            label: {
                // padding: [11, 5, 7],
                padding: [0, 0, 10, 0],
                /*
    除了padding[0]建议必须是0之外,其他三项可随意设置
    
    和CSSpadding相同,[上,右,下,左]
    
    如果需要下边线超出文字,设左右padding即可,注:左右padding最好相同
    
    padding[2]的10:
    
    10 = 文字距下边线的距离 + 下边线的宽度
                
    如:UI图中文字距下边线距离为7 下边线宽度为2
    
    则padding: [0, 0, 9, 0]
                
                */
                // 这里的margin和axisLabel的margin要一致!
                margin: 15,
                // 移入时的字体大小
                fontSize: 14,
                backgroundColor: {
                    type: 'linear',
                    x: 0,
                    y: 0,
                    x2: 0,
                    y2: 1,
                    colorStops: [{
                        offset: 0,
                        color: '#fff' // 0% 处的颜色
                    }, {
                        // offset: 0.9,
                        offset: 0.86,
                        /*
0.86 = (文字 + 文字距下边线的距离)/(文字 + 文字距下边线的距离 + 下边线的宽度)
                        
                        */
                        color: '#fff' // 0% 处的颜色
                    }, {
                        offset: 0.86,
                        color: '#33c0cd' // 0% 处的颜色
                    }, {
                        offset: 1,
                        color: '#33c0cd' // 100% 处的颜色
                    }],
                    global: false // 缺省为 false
                }
            }
        },
        boundaryGap: false
    }],
    yAxis: [{
        name:'水位(m)',
		nameTextStyle: {
			color: ['#556677']
		},
        type: 'value',
        axisTick: {
            show: false
        },
        min: 263,
        minInterval: 1,
        axisLine: {
            show: true,
            lineStyle: {
                color: '#DCE2E8'
            }
        },
        axisLabel: {
            textStyle: {
                color: '#556677'
            }
        },
        splitLine: {
            show: false
        }
    }, {
        name:'库容(万m³)',
		nameTextStyle: {
			color: ['#556677']
		},
        type: 'value',
        position: 'right',
        axisTick: {
            show: false
        },
        axisLabel: {
            textStyle: {
                color: '#556677'
            },
            formatter:function(value,index){
                console.log(value)
                return value;
            },
        },
        axisLine: {
            show: true,
            lineStyle: {
                color: '#DCE2E8'
            }
        },
        splitLine: {
            show: false
        }
    }],
    series: [{
            name: '水位',
            type: 'line',
            data: [264.03, 264.03, 264.03, 264.04, 264.04, 264.04, 264.05, 264.05, 264.06, 264.06, 264.06, 264.07, 264.06, 264.07, 264.07, 264.08, 264.08, 264.09, 264.09, 264.09, 264.1, 264.1, 264.1, 264.11, 264.11, 264.12, 264.13, 264.14, 264.14, 264.15, 264.16, 264.16, 264.16, 264.16, 264.16, 264.16, 264.17, 264.18, 264.19, 264.19, 264.2, 264.2, 264.2, 264.21, 264.21, 264.21, 264.21, 264.22, 264.22, 264.22, 264.22, 264.22, 264.22, 264.23, 264.23, 264.23, 264.23, 264.23, 264.22, 264.22, 264.22, 264.23, 264.22, 264.23, 264.23, 264.23, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.25, 264.24, 264.24, 264.25, 264.25, 264.25, 264.25, 264.25, 264.25, 264.25, 264.25, 264.24, 264.24, 264.23, 264.22, 264.22, 264.23, 264.23, 264.23, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.25, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.24, 264.23, 264.23],
            symbolSize: 1,
            symbol: 'circle',
            smooth: true,
            yAxisIndex: 0,
            showSymbol: false,
            lineStyle: {
                width: 2,
                color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [{
                        offset: 0,
                        color: '#9effff'
                    },
                    {
                        offset: 1,
                        color: '#9E87FF'
                    }
                ]),
                // shadowColor: 'rgba(158,135,255, 0.3)',
                // shadowBlur: 10,
                // shadowOffsetY: 20
            },
            itemStyle: {
                normal: {
                    color: colorList[0],
                    borderColor: colorList[0]
                }
            }
        },
        {
            name: '库容',
            type: 'line',
            data: [1604, 1604, 1604, 1607, 1607, 1607, 1610, 1610, 1613, 1613, 1613, 1617.5, 1613, 1617.5, 1617.5, 1622, 1622, 1626, 1626, 1626, 1628.5, 1628.5, 1628.5, 1632.5, 1632.5, 1635.5, 1638, 1642.5, 1642.5, 1645.5, 1648, 1648, 1648, 1648, 1648, 1648, 1652.5, 1655.5, 1658, 1658, 1661, 1661, 1661, 1665.5, 1665.5, 1665.5, 1665.5, 1668.5, 1668.5, 1668.5, 1668.5, 1668.5, 1668.5, 1671, 1671, 1671, 1671, 1671, 1668.5, 1668.5, 1668.5, 1671, 1668.5, 1671, 1671, 1671, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1678.5, 1675.5, 1675.5, 1678.5, 1678.5, 1678.5, 1678.5, 1678.5, 1678.5, 1678.5, 1678.5, 1675.5, 1675.5, 1671, 1668.5, 1668.5, 1671, 1671, 1671, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1678.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1675.5, 1671, 1671],
            symbolSize: 1,
            yAxisIndex: 1,
            symbol: 'circle',
            smooth: true,
            showSymbol: false,
            lineStyle: {
                width: 2,
                color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [{
                        offset: 0,
                        color: '#fe9a'
                    },
                    {
                        offset: 1,
                        color: '#fe9a8b'
                    }
                ]),
                // shadowColor: 'rgba(254,154,139, 0.3)',
                // shadowBlur: 10,
                // shadowOffsetY: 20
            },
            itemStyle: {
                normal: {
                    color: colorList[2],
                    borderColor: colorList[2]
                }
            }
        }
    ]
};