echarts实现水波球和立体柱状图

在这里插入图片描述

<template>
  <div class="sfgc-page">
    <div class="so2-box basic-box">
      <div class="title-box">
        <span>SO2排放量</span>
      </div>

      <div class="echart-box">
        <div class="left-box">
          <div class="echart" ref="chart11"></div>
        </div>
        <div class="right-box">
          <p>年度目标</p>
          <p>8.87 <em>万吨</em></p>
        </div>
      </div>

      <div class="bottom-box">
        <div class="echart" ref="chart12"></div>
      </div>
    </div>

    <div class="nox-box basic-box">
      <div class="title-box">
        <span>NOX排放量</span>
      </div>

      <div class="echart-box">
        <div class="left-box">
          <div class="echart" ref="chart21"></div>
        </div>
        <div class="right-box">
          <p>年度目标</p>
          <p>16.72 <em>万吨</em></p>
        </div>
      </div>

      <div class="bottom-box">
        <div class="echart" ref="chart22"></div>
      </div>
    </div>

    <div class="cod-box basic-box">
      <div class="title-box">
        <span>COD排放量</span>
      </div>

      <div class="echart-box">
        <div class="left-box">
          <div class="echart" ref="chart31"></div>
        </div>
        <div class="right-box">
          <p>年度目标</p>
          <p>0.39 <em>万吨</em></p>
        </div>
      </div>

      <div class="bottom-box">
        <div class="echart" ref="chart32"></div>
      </div>
    </div>

    <div class="air-box basic-box">
      <div class="title-box">
        <span>露天矿排土场复垦率</span>
      </div>

      <div class="echart-box">
        <div class="left-box">
          <div class="echart" ref="chart41"></div>
        </div>
        <div class="right-box">
          <p>年度目标</p>
          <p>100 <em>%</em></p>
        </div>
      </div>

      <div class="bottom-box">
        <div class="echart" ref="chart42"></div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      chart11: null,
      chart12: null,

      chart21: null,
      chart22: null,

      chart31: null,
      chart32: null,

      chart41: null,
      chart42: null
    }
  },

  methods: {
    initChart11() {
      //销毁
      this.chart11 && this.$echarts.dispose(this.chart11)
      //基于准备好的dom,初始化echarts实例
      this.chart11 = this.$echarts.init(this.$refs.chart11)

      let chartOption11 = {
        title: {
          text: '3.13 万吨',
          textStyle: {
            fontSize: 50,
            fontFamily: 'Microsoft Yahei',
            fontWeight: 'normal',
            color: '#fff',
            fontWeight: 'bold'
          },
          x: 'center',
          y: '45%'
        },

        graphic: [
          {
            type: 'group',
            left: 'center',
            top: '65%',
            children: [
              {
                type: 'text',
                z: 100,
                // left: '100',
                // top: 'middle',
                style: {
                  fill: '#fff',
                  text: '排放量',
                  font: '33px Microsoft YaHei'
                }
              }
            ]
          }
        ],

        // x轴
        xAxis: {
          show: false // 不显示
        },
        // y轴
        yAxis: {
          axisLine: {
            show: false
          },
          axisLabel: {
            fontSize: 18,
            color: '#d8bb93'
          }
        },
        grid: {},

        series: [
          {
            type: 'liquidFill',
            color: [
              {
                type: 'linear',
                x: 0,
                y: 0,
                x2: 0,
                y2: 1,
                colorStops: [
                  {
                    offset: 1,
                    color: 'rgba(133, 94, 21,1)'
                  },
                  {
                    offset: 0.5,
                    color: 'rgba(133, 94, 21,1)'
                  },
                  {
                    offset: 0,
                    color: 'rgba(133, 94, 21,1)'
                  }
                ],
                globalCoord: false
              }
            ],
            radius: '85%', // 半径大小
            center: ['50%', '50%'], // 布局位置
            data: [13.22 / 16.76, 13.22 / 16.76], // 水球波纹值
            backgroundStyle: {
              color: 'rgba(0,0,0,0)' //背景颜色
            },
            outline: {
              // 轮廓设置
              show: true,
              borderDistance: 20, // 轮廓间距
              itemStyle: {
                borderColor: '#855e15', // 轮廓颜色
                borderWidth: 5, // 轮廓大小
                shadowBlur: 'none' // 轮廓阴影
              }
            },
            label: {
              show: false
            }
          }
        ]
      }
      this.chart11.setOption(chartOption11, true)
      this.chart11 && this.chart11.resize()
    },
    resizeChart11() {
      this.chart11 && this.chart11.resize()
    },
    initChart12() {
      //销毁
      this.chart12 && this.$echarts.dispose(this.chart12)
      //基于准备好的dom,初始化echarts实例
      this.chart12 = this.$echarts.init(this.$refs.chart12)

      let chartOption12 = {
        tooltip: {
          trigger: 'axis',
          textStyle: {
            color: '#ffffff',
            fontSize: 30
          },
          formatter(params) {
            const item = params[1] || {}
            if (JSON.stringify(item) !== '{}') {
              return `
                  <div class='chart-tooltip'>
                    <span class='title'>${item.axisValueLabel}</span>
                    <span class='text'><span class='point'></span>${item.data}</span>
                  </div>`
            }
            return `暂无数据`
          }
        },

        grid: {
          containLabel: true
        },

        xAxis: [
          {
            type: 'category',
            data: ['2019年', '2020年', '2021年'],
            axisLine: { show: false },
            axisTick: {
              show: false
            },
            axisLabel: {
              show: true,
              fontSize: 30,
              color: '#d9bb96',
              fontFamily: 'Microsoft YaHei',
              margin: 30
            }
          }
        ],
        yAxis: [
          {
            type: 'value',
            axisLine: { show: false },
            nameTextStyle: {
              align: 'right',
              color: '#ffffff',
              fontSize: 8,
              fontFamily: 'Microsoft YaHei'
            },
            axisTick: {
              show: false
            },
            axisLabel: {
              show: false,
              fontSize: 8,
              color: '#ffffff',
              fontFamily: 'Microsoft YaHei'
            },
            splitLine: {
              show: false
            }
          }
        ],
        series: [
          {
            //柱底圆片
            name: '',
            type: 'pictorialBar',
            symbolSize: [50, 20],
            symbolOffset: [0, 10],
            z: 12,
            itemStyle: {
              normal: {
                color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [
                  {
                    offset: 0,
                    color: '#c0eb59'
                  },
                  {
                    offset: 1,
                    color: '#c0eb59'
                  }
                ])
              }
            },
            data: ['6.77', '6.58', '7.71']
          },

          //柱体
          {
            name: '',
            type: 'bar',
            barWidth: 50,
            barGap: '0%',
            itemStyle: {
              normal: {
                color: {
                  x: 0,
                  y: 0,
                  x2: 0,
                  y2: 1,
                  type: 'linear',
                  global: false,
                  colorStops: [
                    {
                      //第一节下面
                      offset: 0,
                      color: '#5f7d32'
                    },
                    {
                      offset: 1,
                      color: '#4b8425'
                    }
                  ]
                }
              }
            },
            label: {
              show: true, // 开启显示
              position: 'top', // 在上方显示
              distance: 50, // 距离图形元素的距离。当 position 为字符描述值(如 'top'、'insideRight')时候有效。
              verticalAlign: 'middle',
              textStyle: {
                // 数值样式
                color: '#d9bb96',
                fontSize: 30
              }
            },
            data: ['6.77', '6.58', '7.71']
          },

          //柱顶圆片
          {
            name: '',
            type: 'pictorialBar',
            symbolSize: [50, 20],
            symbolOffset: [0, -10],
            z: 12,
            symbolPosition: 'end',
            itemStyle: {
              normal: {
                color: new this.$echarts.graphic.LinearGradient(
                  0,
                  0,
                  0,
                  1,
                  [
                    {
                      offset: 0,
                      color: '#c0eb59'
                    },
                    {
                      offset: 1,
                      color: '#c0eb59'
                    }
                  ],
                  false
                )
              }
            },
            data: ['6.77', '6.58', '7.71']
          }
        ]
      }
      this.chart12.setOption(chartOption12, true)
      this.chart12 && this.chart12.resize()
    },
    resizeChart12() {
      this.chart12 && this.chart12.resize()
    },

    initChart21() {
      //销毁
      this.chart21 && this.$echarts.dispose(this.chart21)
      //基于准备好的dom,初始化echarts实例
      this.chart21 = this.$echarts.init(this.$refs.chart21)

      let chartOption21 = {
        title: {
          text: '7.3 万吨',
          textStyle: {
            fontSize: 50,
            fontFamily: 'Microsoft Yahei',
            fontWeight: 'normal',
            color: '#fff',
            fontWeight: 'bold'
          },
          x: 'center',
          y: '45%'
        },

        graphic: [
          {
            type: 'group',
            left: 'center',
            top: '65%',
            children: [
              {
                type: 'text',
                z: 100,
                // left: '100',
                // top: 'middle',
                style: {
                  fill: '#fff',
                  text: '排放量',
                  font: '33px Microsoft YaHei'
                }
              }
            ]
          }
        ],

        // x轴
        xAxis: {
          show: false // 不显示
        },
        // y轴
        yAxis: {
          axisLine: {
            show: false
          },
          axisLabel: {
            fontSize: 18,
            color: '#d8bb93'
          }
        },
        grid: {},

        series: [
          {
            type: 'liquidFill',
            color: [
              {
                type: 'linear',
                x: 0,
                y: 0,
                x2: 0,
                y2: 1,
                colorStops: [
                  {
                    offset: 1,
                    color: 'rgba(140, 30, 38,1)'
                  },
                  {
                    offset: 0.5,
                    color: 'rgba(140, 30, 38,1)'
                  },
                  {
                    offset: 0,
                    color: 'rgba(140, 30, 38,1)'
                  }
                ],
                globalCoord: false
              }
            ],
            radius: '85%', // 半径大小
            center: ['50%', '50%'], // 布局位置
            data: [13.22 / 16.76, 13.22 / 16.76], // 水球波纹值
            backgroundStyle: {
              color: 'rgba(0,0,0,0)' //背景颜色
            },
            outline: {
              // 轮廓设置
              show: true,
              borderDistance: 20, // 轮廓间距
              itemStyle: {
                borderColor: '#8c1e26', // 轮廓颜色
                borderWidth: 5, // 轮廓大小
                shadowBlur: 'none' // 轮廓阴影
              }
            },
            label: {
              show: false
            }
          }
        ]
      }
      this.chart21.setOption(chartOption21, true)
      this.chart21 && this.chart21.resize()
    },
    resizeChart21() {
      this.chart21 && this.chart21.resize()
    },
    initChart22() {
      //销毁
      this.chart22 && this.$echarts.dispose(this.chart22)
      //基于准备好的dom,初始化echarts实例
      this.chart22 = this.$echarts.init(this.$refs.chart22)

      let chartOption22 = {
        tooltip: {
          trigger: 'axis',
          textStyle: {
            color: '#ffffff',
            fontSize: 30
          },
          formatter(params) {
            const item = params[1] || {}
            if (JSON.stringify(item) !== '{}') {
              return `
                  <div class='chart-tooltip'>
                    <span class='title'>${item.axisValueLabel}</span>
                    <span class='text'><span class='point'></span>${item.data}</span>
                  </div>`
            }
            return `暂无数据`
          }
        },

        grid: {
          containLabel: true
        },

        xAxis: [
          {
            type: 'category',
            data: ['2019年', '2020年', '2021年'],
            axisLine: { show: false },
            axisTick: {
              show: false
            },
            axisLabel: {
              show: true,
              fontSize: 30,
              color: '#d9bb96',
              fontFamily: 'Microsoft YaHei',
              margin: 30
            }
          }
        ],
        yAxis: [
          {
            type: 'value',
            axisLine: { show: false },
            nameTextStyle: {
              align: 'right',
              color: '#ffffff',
              fontSize: 8,
              fontFamily: 'Microsoft YaHei'
            },
            axisTick: {
              show: false
            },
            axisLabel: {
              show: false,
              fontSize: 8,
              color: '#ffffff',
              fontFamily: 'Microsoft YaHei'
            },
            splitLine: {
              show: false
            }
          }
        ],
        series: [
          {
            //柱底圆片
            name: '',
            type: 'pictorialBar',
            symbolSize: [50, 20],
            symbolOffset: [0, 10],
            z: 12,
            itemStyle: {
              normal: {
                color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [
                  {
                    offset: 0,
                    color: '#c0eb59'
                  },
                  {
                    offset: 1,
                    color: '#c0eb59'
                  }
                ])
              }
            },
            data: ['6.77', '6.58', '7.71']
          },

          //柱体
          {
            name: '',
            type: 'bar',
            barWidth: 50,
            barGap: '0%',
            itemStyle: {
              normal: {
                color: {
                  x: 0,
                  y: 0,
                  x2: 0,
                  y2: 1,
                  type: 'linear',
                  global: false,
                  colorStops: [
                    {
                      //第一节下面
                      offset: 0,
                      color: '#5f7d32'
                    },
                    {
                      offset: 1,
                      color: '#4b8425'
                    }
                  ]
                }
              }
            },
            label: {
              show: true, // 开启显示
              position: 'top', // 在上方显示
              distance: 50, // 距离图形元素的距离。当 position 为字符描述值(如 'top'、'insideRight')时候有效。
              verticalAlign: 'middle',
              textStyle: {
                // 数值样式
                color: '#d9bb96',
                fontSize: 30
              }
            },
            data: ['6.77', '6.58', '7.71']
          },

          //柱顶圆片
          {
            name: '',
            type: 'pictorialBar',
            symbolSize: [50, 20],
            symbolOffset: [0, -10],
            z: 12,
            symbolPosition: 'end',
            itemStyle: {
              normal: {
                color: new this.$echarts.graphic.LinearGradient(
                  0,
                  0,
                  0,
                  1,
                  [
                    {
                      offset: 0,
                      color: '#c0eb59'
                    },
                    {
                      offset: 1,
                      color: '#c0eb59'
                    }
                  ],
                  false
                )
              }
            },
            data: ['6.77', '6.58', '7.71']
          }
        ]
      }
      this.chart22.setOption(chartOption22, true)
      this.chart22 && this.chart22.resize()
    },
    resizeChart22() {
      this.chart22 && this.chart22.resize()
    },

    initChart31() {
      //销毁
      this.chart31 && this.$echarts.dispose(this.chart31)
      //基于准备好的dom,初始化echarts实例
      this.chart31 = this.$echarts.init(this.$refs.chart31)

      let chartOption31 = {
        title: {
          text: '0.13 万吨',
          textStyle: {
            fontSize: 50,
            fontFamily: 'Microsoft Yahei',
            fontWeight: 'normal',
            color: '#fff',
            fontWeight: 'bold'
          },
          x: 'center',
          y: '45%'
        },

        graphic: [
          {
            type: 'group',
            left: 'center',
            top: '65%',
            children: [
              {
                type: 'text',
                z: 100,
                // left: '100',
                // top: 'middle',
                style: {
                  fill: '#fff',
                  text: '排放量',
                  font: '33px Microsoft YaHei'
                }
              }
            ]
          }
        ],

        // x轴
        xAxis: {
          show: false // 不显示
        },
        // y轴
        yAxis: {
          axisLine: {
            show: false
          },
          axisLabel: {
            fontSize: 18,
            color: '#d8bb93'
          }
        },
        grid: {},

        series: [
          {
            type: 'liquidFill',
            color: [
              {
                type: 'linear',
                x: 0,
                y: 0,
                x2: 0,
                y2: 1,
                colorStops: [
                  {
                    offset: 1,
                    color: 'rgba(81, 86, 187,1)'
                  },
                  {
                    offset: 0.5,
                    color: 'rgba(81, 86, 187,1)'
                  },
                  {
                    offset: 0,
                    color: 'rgba(81, 86, 187,1)'
                  }
                ],
                globalCoord: false
              }
            ],
            radius: '85%', // 半径大小
            center: ['50%', '50%'], // 布局位置
            data: [13.22 / 16.76, 13.22 / 16.76], // 水球波纹值
            backgroundStyle: {
              color: 'rgba(0,0,0,0)' //背景颜色
            },
            outline: {
              // 轮廓设置
              show: true,
              borderDistance: 20, // 轮廓间距
              itemStyle: {
                borderColor: '#5156bb', // 轮廓颜色
                borderWidth: 5, // 轮廓大小
                shadowBlur: 'none' // 轮廓阴影
              }
            },
            label: {
              show: false
            }
          }
        ]
      }
      this.chart31.setOption(chartOption31, true)
      this.chart31 && this.chart31.resize()
    },
    resizeChart31() {
      this.chart31 && this.chart31.resize()
    },
    initChart32() {
      //销毁
      this.chart32 && this.$echarts.dispose(this.chart32)
      //基于准备好的dom,初始化echarts实例
      this.chart32 = this.$echarts.init(this.$refs.chart32)

      let chartOption32 = {
        tooltip: {
          trigger: 'axis',
          textStyle: {
            color: '#ffffff',
            fontSize: 30
          },
          formatter(params) {
            const item = params[1] || {}
            if (JSON.stringify(item) !== '{}') {
              return `
                  <div class='chart-tooltip'>
                    <span class='title'>${item.axisValueLabel}</span>
                    <span class='text'><span class='point'></span>${item.data}</span>
                  </div>`
            }
            return `暂无数据`
          }
        },

        grid: {
          containLabel: true
        },

        xAxis: [
          {
            type: 'category',
            data: ['2019年', '2020年', '2021年'],
            axisLine: { show: false },
            axisTick: {
              show: false
            },
            axisLabel: {
              show: true,
              fontSize: 30,
              color: '#d9bb96',
              fontFamily: 'Microsoft YaHei',
              margin: 30
            }
          }
        ],
        yAxis: [
          {
            type: 'value',
            axisLine: { show: false },
            nameTextStyle: {
              align: 'right',
              color: '#ffffff',
              fontSize: 8,
              fontFamily: 'Microsoft YaHei'
            },
            axisTick: {
              show: false
            },
            axisLabel: {
              show: false,
              fontSize: 8,
              color: '#ffffff',
              fontFamily: 'Microsoft YaHei'
            },
            splitLine: {
              show: false
            }
          }
        ],
        series: [
          {
            //柱底圆片
            name: '',
            type: 'pictorialBar',
            symbolSize: [50, 20],
            symbolOffset: [0, 10],
            z: 12,
            itemStyle: {
              normal: {
                color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [
                  {
                    offset: 0,
                    color: '#c0eb59'
                  },
                  {
                    offset: 1,
                    color: '#c0eb59'
                  }
                ])
              }
            },
            data: ['6.77', '6.58', '7.71']
          },

          //柱体
          {
            name: '',
            type: 'bar',
            barWidth: 50,
            barGap: '0%',
            itemStyle: {
              normal: {
                color: {
                  x: 0,
                  y: 0,
                  x2: 0,
                  y2: 1,
                  type: 'linear',
                  global: false,
                  colorStops: [
                    {
                      //第一节下面
                      offset: 0,
                      color: '#5f7d32'
                    },
                    {
                      offset: 1,
                      color: '#4b8425'
                    }
                  ]
                }
              }
            },
            label: {
              show: true, // 开启显示
              position: 'top', // 在上方显示
              distance: 50, // 距离图形元素的距离。当 position 为字符描述值(如 'top'、'insideRight')时候有效。
              verticalAlign: 'middle',
              textStyle: {
                // 数值样式
                color: '#d9bb96',
                fontSize: 30
              }
            },
            data: ['6.77', '6.58', '7.71']
          },

          //柱顶圆片
          {
            name: '',
            type: 'pictorialBar',
            symbolSize: [50, 20],
            symbolOffset: [0, -10],
            z: 12,
            symbolPosition: 'end',
            itemStyle: {
              normal: {
                color: new this.$echarts.graphic.LinearGradient(
                  0,
                  0,
                  0,
                  1,
                  [
                    {
                      offset: 0,
                      color: '#c0eb59'
                    },
                    {
                      offset: 1,
                      color: '#c0eb59'
                    }
                  ],
                  false
                )
              }
            },
            data: ['6.77', '6.58', '7.71']
          }
        ]
      }
      this.chart32.setOption(chartOption32, true)
      this.chart32 && this.chart32.resize()
    },
    resizeChart32() {
      this.chart32 && this.chart32.resize()
    },

    initChart41() {
      //销毁
      this.chart41 && this.$echarts.dispose(this.chart41)
      //基于准备好的dom,初始化echarts实例
      this.chart41 = this.$echarts.init(this.$refs.chart41)

      let chartOption41 = {
        title: {
          text: '87.65 %',
          textStyle: {
            fontSize: 50,
            fontFamily: 'Microsoft Yahei',
            fontWeight: 'normal',
            color: '#fff',
            fontWeight: 'bold'
          },
          x: 'center',
          y: '45%'
        },

        graphic: [
          {
            type: 'group',
            left: 'center',
            top: '65%',
            children: [
              {
                type: 'text',
                z: 100,
                // left: '100',
                // top: 'middle',
                style: {
                  fill: '#fff',
                  text: '排放量',
                  font: '33px Microsoft YaHei'
                }
              }
            ]
          }
        ],

        // x轴
        xAxis: {
          show: false // 不显示
        },
        // y轴
        yAxis: {
          axisLine: {
            show: false
          },
          axisLabel: {
            fontSize: 18,
            color: '#d8bb93'
          }
        },
        grid: {},

        series: [
          {
            type: 'liquidFill',
            color: [
              {
                type: 'linear',
                x: 0,
                y: 0,
                x2: 0,
                y2: 1,
                colorStops: [
                  {
                    offset: 1,
                    color: 'rgba(81, 140, 30,1)'
                  },
                  {
                    offset: 0.5,
                    color: 'rgba(81, 140, 30,1)'
                  },
                  {
                    offset: 0,
                    color: 'rgba(81, 140, 30,1)'
                  }
                ],
                globalCoord: false
              }
            ],
            radius: '85%', // 半径大小
            center: ['50%', '50%'], // 布局位置
            data: ['0.8', '0.8'], // 水球波纹值
            backgroundStyle: {
              color: 'rgba(0,0,0,0)' //背景颜色
            },
            outline: {
              // 轮廓设置
              show: true,
              borderDistance: 20, // 轮廓间距
              itemStyle: {
                borderColor: '#518c1e', // 轮廓颜色
                borderWidth: 5, // 轮廓大小
                shadowBlur: 'none' // 轮廓阴影
              }
            },
            label: {
              show: false
            }
          }
        ]
      }
      this.chart41.setOption(chartOption41, true)
      this.chart41 && this.chart41.resize()
    },
    resizeChart41() {
      this.chart41 && this.chart41.resize()
    },
    initChart42() {
      //销毁
      this.chart42 && this.$echarts.dispose(this.chart42)
      //基于准备好的dom,初始化echarts实例
      this.chart42 = this.$echarts.init(this.$refs.chart42)

      let chartOption42 = {
        tooltip: {
          trigger: 'axis',
          textStyle: {
            color: '#ffffff',
            fontSize: 30
          },
          formatter(params) {
            const item = params[1] || {}
            if (JSON.stringify(item) !== '{}') {
              return `
                  <div class='chart-tooltip'>
                    <span class='title'>${item.axisValueLabel}</span>
                    <span class='text'><span class='point'></span>${item.data}</span>
                  </div>`
            }
            return `暂无数据`
          }
        },

        grid: {
          containLabel: true
        },

        xAxis: [
          {
            type: 'category',
            data: ['2019年', '2020年', '2021年'],
            axisLine: { show: false },
            axisTick: {
              show: false
            },
            axisLabel: {
              show: true,
              fontSize: 30,
              color: '#d9bb96',
              fontFamily: 'Microsoft YaHei',
              margin: 30
            }
          }
        ],
        yAxis: [
          {
            type: 'value',
            axisLine: { show: false },
            nameTextStyle: {
              align: 'right',
              color: '#ffffff',
              fontSize: 8,
              fontFamily: 'Microsoft YaHei'
            },
            axisTick: {
              show: false
            },
            axisLabel: {
              show: false,
              fontSize: 8,
              color: '#ffffff',
              fontFamily: 'Microsoft YaHei'
            },
            splitLine: {
              show: false
            }
          }
        ],
        series: [
          {
            //柱底圆片
            name: '',
            type: 'pictorialBar',
            symbolSize: [50, 20],
            symbolOffset: [0, 10],
            z: 12,
            itemStyle: {
              normal: {
                color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [
                  {
                    offset: 0,
                    color: '#c0eb59'
                  },
                  {
                    offset: 1,
                    color: '#c0eb59'
                  }
                ])
              }
            },
            data: ['6.77', '6.58', '7.71']
          },

          //柱体
          {
            name: '',
            type: 'bar',
            barWidth: 50,
            barGap: '0%',
            itemStyle: {
              normal: {
                color: {
                  x: 0,
                  y: 0,
                  x2: 0,
                  y2: 1,
                  type: 'linear',
                  global: false,
                  colorStops: [
                    {
                      //第一节下面
                      offset: 0,
                      color: '#5f7d32'
                    },
                    {
                      offset: 1,
                      color: '#4b8425'
                    }
                  ]
                }
              }
            },
            label: {
              show: true, // 开启显示
              position: 'top', // 在上方显示
              distance: 50, // 距离图形元素的距离。当 position 为字符描述值(如 'top'、'insideRight')时候有效。
              verticalAlign: 'middle',
              textStyle: {
                // 数值样式
                color: '#d9bb96',
                fontSize: 30
              }
            },
            data: ['6.77', '6.58', '7.71']
          },

          //柱顶圆片
          {
            name: '',
            type: 'pictorialBar',
            symbolSize: [50, 20],
            symbolOffset: [0, -10],
            z: 12,
            symbolPosition: 'end',
            itemStyle: {
              normal: {
                color: new this.$echarts.graphic.LinearGradient(
                  0,
                  0,
                  0,
                  1,
                  [
                    {
                      offset: 0,
                      color: '#c0eb59'
                    },
                    {
                      offset: 1,
                      color: '#c0eb59'
                    }
                  ],
                  false
                )
              }
            },
            data: ['6.77', '6.58', '7.71']
          }
        ]
      }
      this.chart42.setOption(chartOption42, true)
      this.chart42 && this.chart42.resize()
    },
    resizeChart42() {
      this.chart42 && this.chart42.resize()
    }
  },

  mounted() {
    this.$nextTick(() => {
      this.initChart11()
      this.initChart12()
      this.initChart21()
      this.initChart22()
      this.initChart31()
      this.initChart32()
      this.initChart41()
      this.initChart42()
    })

    window.addEventListener('resize', this.resizeChart11)
    window.addEventListener('resize', this.resizeChart12)
    window.addEventListener('resize', this.resizeChart21)
    window.addEventListener('resize', this.resizeChart22)
    window.addEventListener('resize', this.resizeChart31)
    window.addEventListener('resize', this.resizeChart32)
    window.addEventListener('resize', this.resizeChart41)
    window.addEventListener('resize', this.resizeChart42)
  },

  beforeDestroy() {
    window.removeEventListener('resize', this.resizeChart11)
    window.removeEventListener('resize', this.resizeChart12)
    window.removeEventListener('resize', this.resizeChart21)
    window.removeEventListener('resize', this.resizeChart22)
    window.removeEventListener('resize', this.resizeChart31)
    window.removeEventListener('resize', this.resizeChart32)
    window.removeEventListener('resize', this.resizeChart41)
    window.removeEventListener('resize', this.resizeChart42)
  }
}
</script>

<style lang="less" scoped>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.sfgc-page {
  display: flex;
  width: 100%;
  height: 920px;
  //   background-color: red;

  ::v-deep .chart-tooltip {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    padding: 2px 4px;
    .title {
      padding: 0 !important;
      margin: 0 !important;
      background: none !important;
      margin-bottom: 6px !important;
    }
    .text {
      display: flex;
      align-items: center;
      .point {
        display: inline-block;
        width: 20px;
        height: 20px;
        border-radius: 50%;
        background-color: #428720;
        margin-right: 6px;
      }
    }
  }

  .basic-box {
    position: relative;
    width: 750px;
    height: 100%;
    padding-left: 10px;
    // user-select: none;
    // background-color: #fff;

    .echart {
      width: 100%;
      height: 100%;
    }

    .title-box {
      width: 100%;
      height: 10%;
      font-size: 40px;
      padding-left: 30px;
      font-weight: 700;
      //   background-color: red;
    }

    .echart-box {
      display: flex;
      width: 100%;
      height: 45%;
      padding-left: 40px;
      //   background-color: green;

      .left-box {
        flex-shrink: 0;
        width: 55%;
        height: 100%;
        // background-color: #fff;
      }

      .right-box {
        flex-shrink: 0;
        width: 45%;
        height: 100%;
        padding-top: 120px;
        padding-left: 20px;
        // background-color: #fff;

        p {
          &:nth-child(1) {
            font-size: 40px;
            margin-bottom: 25px;
          }

          &:nth-child(2) {
            font-size: 70px;
            color: #fff;
            font-weight: 700;

            em {
              font-size: 35px;
              font-weight: normal;
            }
          }
        }
      }
    }

    .bottom-box {
      width: 100%;
      height: 45%;
      //   background-color: blue;
    }
  }

  .so2-box {
    &::after {
      content: '';
      position: absolute;
      right: 0;
      bottom: 0;
      width: 1px;
      height: 850px;
      background-color: #d9bb95;
    }
  }

  .nox-box {
    &::after {
      content: '';
      position: absolute;
      right: 0;
      bottom: 0;
      width: 1px;
      height: 850px;
      background-color: #d9bb95;
    }
  }

  .cod-box {
    &::after {
      content: '';
      position: absolute;
      right: 0;
      bottom: 0;
      width: 1px;
      height: 850px;
      background-color: #d9bb95;
    }
  }

  .air-box {
    background-color: transparent;
  }
}
</style>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值