派生自 wuyushui/SewerAndRainNetwork

chenzeping
2021-03-05 16db39abe5b733764c760c7d3d754798cbe77c43
src/components/mapmodules/SafetyIndexLine.js
@@ -1,107 +1,109 @@
import echarts from 'echarts'
import dayjs from 'dayjs'
function drawSafetyLine() {
    let myChart = echarts.init(document.getElementById('safetyIndex'))
    let yyyy = dayjs().format('YYYY') + '-'
    let resDate = ['07-10', '07-11', '07-12', '07-13', '07-14', '07-15', '07-16']
    let resValue = [35, 20, 10, 20, 40, 30, 10]
    let safetyStandardValue = 20
    myChart.setOption({
        tooltip: {
            trigger: 'axis',
            formatter: '<span style="text-align: center;display:block; color: #33FF90">' + yyyy + '{b0}</span>' +
function drawSafetyLine () {
  const myChart = echarts.init(document.getElementById('safetyIndex'))
  const yyyy = dayjs().format('YYYY') + '-'
  const resDate = ['07-10', '07-11', '07-12', '07-13', '07-14', '07-15', '07-16']
  const resValue = [35, 20, 10, 20, 40, 30, 10]
  const safetyStandardValue = 20
  myChart.setOption({
    tooltip: {
      trigger: 'axis',
      formatter: '<span style="text-align: center;display:block; color: #33FF90">' + yyyy + '{b0}</span>' +
                '<span style="color: #33FF90">{a0}:{c0}</span><br/>' +
                '<span style="color: #33FF90">安全标准指数:' + safetyStandardValue + '</span>', // 自定义tip格式
            backgroundColor: 'rgba(73,177,231, 0.1)',
            axisPointer: {
                lineStyle: {
                    color: 'rgba(73,177,231, 0.5)',
                    type: 'dashed'
                }
      backgroundColor: 'rgba(73,177,231, 0.1)',
      axisPointer: {
        lineStyle: {
          color: 'rgba(73,177,231, 0.5)',
          type: 'dashed'
        }
      }
    },
    grid: {
      left: '4%',
      right: '10%',
      bottom: '3%',
      containLabel: true
    },
    xAxis: {
      type: 'category',
      boundaryGap: false,
      data: resDate,
      axisLine: {
        show: false,
        lineStyle: {
          color: '#33FFF8'
        }
      },
      axisTick: { // x轴刻度线
        show: false
      }
    },
    yAxis: {
      type: 'value',
      splitLine: {
        lineStyle: {
          type: 'dotted', // 设置网格线类型 dotted:虚线 solid:实线
          color: 'rgb(73,177,231, 0.3)'
        },
        show: true
      },
      axisLine: {
        show: false,
        lineStyle: {
          color: '#33FFF8'
        }
      },
      axisTick: { // y轴刻度线
        show: false
      },
      nameTextStyle: {
        lineHeight: 20
      }
    },
    series: [
      {
        name: '安全指数',
        type: 'line',
        data: resValue,
        itemStyle: {
          normal: {
            lineStyle: {
              color: 'rgb(233,209,74)',
              width: 2 // 设置线条粗细
            }
          }
        },
        grid: {
            left: '4%',
            right: '10%',
            bottom: '3%',
            containLabel: true
        },
        xAxis: {
            type: 'category',
            boundaryGap: false,
            data: resDate,
            axisLine: {
                show: false,
                lineStyle: {
                    color: '#33FFF8'
                }
            },
            axisTick: { // x轴刻度线
                show: false
            }
        },
        yAxis: {
            type: 'value',
            splitLine: {
                lineStyle: {
                    type: 'dotted', // 设置网格线类型 dotted:虚线 solid:实线
                    color: 'rgb(73,177,231, 0.3)'
                },
                show: true
            },
            axisLine: {
                show: false,
                lineStyle: {
                    color: '#33FFF8'
                }
            },
            axisTick: { // y轴刻度线
                show: false
            },
            nameTextStyle: {
                lineHeight: 20
            }
        },
        series: [
        markLine: {
          symbol: 'none', // 去掉标准线箭头
          data: [
            {
                name: '安全指数',
                type: 'line',
                data: resValue,
                itemStyle: {
                    normal: {
                        lineStyle: {
                            color: 'rgb(233,209,74)',
                            width: 2 // 设置线条粗细
                        }
                    }
                },
                markLine: {
                    symbol: 'none', // 去掉标准线箭头
                    data: [
                        {
                            label: {
                                normal: {
                                    position: 'end',
                                    formatter: ''
                                }
                            },
                            name: '标准值',
                            yAxis: 20,
                            lineStyle: {
                                type: 'solid',
                                color: '#33FFF8',
                                width: 1
                            }
                        }
                    ]
              label: {
                normal: {
                  position: 'end',
                  formatter: ''
                }
              },
              name: '标准值',
              yAxis: 20,
              lineStyle: {
                type: 'solid',
                color: '#33FFF8',
                width: 1
              }
            }
        ]
    })
    window.addEventListener('resize', () => { myChart.resize() })
          ]
        }
      }
    ]
  })
  window.addEventListener('resize', () => {
    myChart.resize()
  })
}
export default {
    drawSafetyLine
  drawSafetyLine
}