智慧园区前端大屏
linwe
2024-11-13 b8440d9a6b1671cdf0c8f06cdaba2f80a8dac1e6
src/views/survey/components/box/fireContent.vue
@@ -4,9 +4,9 @@
 * @LastEditors: shuishen 1109946754@qq.com
 * @LastEditTime: 2024-11-05 17:42:44
 * @FilePath: \bigScreen\src\views\survey\components\box\fireContent.vue
 * @Description:
 *
 * Copyright (c) 2024 by shuishen, All Rights Reserved.
 * @Description:
 *
 * Copyright (c) 2024 by shuishen, All Rights Reserved.
-->
<script setup>
import { useEchartsResize } from 'hooks/useEchartsResize'
@@ -27,13 +27,14 @@
  {
    name: '一般',
    itemStyle: {
      color: '#FFFF00'
     color: '#FFC000'
    }
  },
  {
    name: '较大',
    itemStyle: {
      color: '#FFC000'
      color: '#F4090F'
    }
  },
  {
@@ -46,105 +47,65 @@
function getRiskSource () {
  getRiskSourceStatistic().then(res => {
    let xaxis_data = []
    let yaxis_data = []
    let seriesData = []
    res.data.data.forEach(element => {
      xaxis_data.push(element.riskLevel)
      yaxis_data.push({
        name: element.riskLevel,
        value: element.num
    let data = res.data.data
    let dataRsult = []
    var total = 0;
    data.forEach(item => {
      dataRsult.push({
        name: item.riskLevel,
        value: item.num,
        itemStyle: typeLevel.find(i => i.name == item.riskLevel).itemStyle
      })
      seriesData.push({
        name: element.riskLevel,
        type: 'bar',
        data: [],
        barWidth: '30',
        barGap: '-100%',
        itemStyle: typeLevel.find(i => i.name == element.riskLevel).itemStyle
      })
    })
    seriesData = seriesData.map(item => {
      return {
        ...item,
        data: yaxis_data.map(i => {
          return i.name == item.name ? i.value : 0
        })
      }
      total = total + item.num;
    })
    myEcharts.setOption({
      title: {
        text: "总数",
        subtext: String(total),
        textStyle: {
          fontSize: 16,
          color: "#fff",
          lineHeight: 20,
        },
        subtextStyle: {
          fontSize: 28,
          color: "#fff",
        },
        textAlign: "center",
        right: "43%",
        top: "36%",
      },
      legend: {
        data: xaxis_data,
        top: "5%",
        right: "5%",
        orient: "vertical",
        top: '8%',
        right: "8%",
        textStyle: {
          color: '#fff'
        }
      },
      tooltip: {
        axisPointer: {
          type: 'shadow'
        }
      },
      grid: {
        top: '16%',
        top: '6%',
        left: '6%',
        right: '6%',
        bottom: '6%',
        containLabel: true
      },
      xAxis: [
        {
          type: 'category',
          data: xaxis_data,
          nameTextStyle: {
            color: '#fff'
          },
          axisLine: {
            lineStyle: {
              color: '#fff'
            }
          },
          axisTick: {
            alignWithLabel: true,
            lineStyle: {
              color: '#fff'
            }
          },
          axisLabel: {
            color: '#fff'
          },
        }
      ],
      tooltip: {
        trigger: 'item'
      },
      yAxis: [
      series: [
        {
          type: 'value',
          nameTextStyle: {
            color: '#fff'
          },
          axisLine: {
            lineStyle: {
              color: '#fff'
            }
          },
          axisTick: {
            lineStyle: {
              color: '#fff'
            }
          },
          axisLabel: {
            color: '#fff'
          },
          // name: 'Access From',
          type: 'pie',
          left: '-5%',
          radius: ['45%', '75%'],
          data: dataRsult
        }
      ],
      series: seriesData
      ]
    })
  })
}
@@ -167,4 +128,4 @@
  </div>
</template>
<style lang="scss" scoped></style>
<style lang="scss" scoped></style>