forked from drone/command-center-dashboard

chenyao
2025-03-31 295eb3cc87aaa5176d64a4ef985cdad0bfefae9a
src/views/Home/components/HomeRight/EventOverview.vue
@@ -8,6 +8,8 @@
import overviewImg5 from '@/assets/images/home/homeRight/overview5.png';
import overviewImg6 from '@/assets/images/home/homeRight/overview6.png';
import completionLeft from '@/assets/images/home/homeRight/completionLeft.png';
import * as echarts from 'echarts';
import CommonDateTime from '@/components/CommonDateTime.vue';
const list = ref([
  { name: '待审核', value: 265, img: overviewImg1, color: '#FF8E8E' },
@@ -18,29 +20,132 @@
  { name: '已完结', value: 262, img: overviewImg6, color: '#8EFFAC' },
]);
const value = ref('');
const echartsRef = ref('');
const options = [
  {
    value: 'Option1',
    label: 'Option1',
  },
  {
    value: 'Option2',
    label: 'Option2',
  },
  {
    value: 'Option3',
    label: 'Option3',
  },
  {
    value: 'Option4',
    label: 'Option4',
  },
  {
    value: 'Option5',
    label: 'Option5',
  },
];
const option = {
  tooltip: {
    trigger: 'axis',
    axisPointer: {
      type: 'shadow',
    },
  },
  grid: {
    top: '5%',
    left: 0,
    right: 0,
    bottom: 0,
    containLabel: true,
  },
  xAxis: [
    {
      type: 'category',
      axisLabel: {
        rotate: -45, // 旋转角度
        interval: 0, // 显示所有标签
        color: '#FFFFFF',
        fontFamily: 'Source Han Sans CN, Source Han Sans CN',
        fontWeight: 400,
        fontSize: 10,
      },
      data: ['暴露垃圾', '占道','暴露垃圾', '占道','暴露垃圾', '占道','暴露垃圾', '占道',],
    },
  ],
  yAxis: [
    {
      type: 'value',
      axisLabel: {
        interval: 0, // 显示所有标签
        color: '#FFFFFF',
        fontFamily: 'Source Han Sans CN, Source Han Sans CN',
        fontWeight: 400,
        fontSize: 10,
      },
      axisLine: {
        lineStyle: {
          color: '#ffffff',
        },
      },
      splitLine: {
        lineStyle: {
          color: 'rgba(255, 255, 255, 0.1)',
          type: 'dashed', // 设置为虚线
        },
      },
    },
  ],
  series: [
    {
      name: '待完成',
      type: 'bar',
      stack: 'Ad',
      emphasis: {
        focus: 'series',
      },
      itemStyle: {
        color: '#FF8E8E', // 设置颜色
      },
      data: [120, 132,120, 132,120, 132,120, 132,],
    },
    {
      name: '已完成',
      type: 'bar',
      stack: 'Ad',
      emphasis: {
        focus: 'series',
      },
      data: [120, 132,120, 132,120, 132,120, 132,],
    },
    {
      name: '已完成1',
      type: 'bar',
      stack: 'Ad',
      emphasis: {
        focus: 'series',
      },
      data: [120, 132,120, 132,120, 132,120, 132,],
    },
    {
      name: '已完成2',
      type: 'bar',
      stack: 'Ad',
      emphasis: {
        focus: 'series',
      },
      data: [120, 132,120, 132,120, 132,120, 132,],
    },
    {
      name: '完成率',
      type: 'line',
      itemStyle: {
        color: '#0CEBF7', // 设置颜色
      },
      lineStyle: {
        width: 2, // 线条宽度
        type: 'solid', // 线条类型
      },
      symbol: 'circle', // 数据点符号
      symbolSize: 6, // 数据点符号大小
      emphasis: {
        focus: 'series',
      },
      data: [50, 55, 60, 65, 70, 75, 80, 85], // 示例数据,根据实际完成率计算
    },
  ],
};
onMounted(() => {
  const chart = echarts.init(echartsRef.value);
  chart.setOption(option);
  window.addEventListener('resize', () => {
    chart.resize();
  });
});
</script>
<template>
@@ -59,6 +164,7 @@
          </div>
        </div>
      </div>
      <CommonDateTime class="dateTime" />
      <el-select class="homeRightSelect" v-model="value" placeholder="请选择" size="large">
        <el-option
@@ -76,9 +182,7 @@
        <img class="completion-left-img" :src="completionLeft" />
      </div>
      <div class="chart">
        <div class="chart-text">echarts柱状图</div>
      </div>
      <div class="chart" ref="echartsRef"></div>
    </div>
  </div>
</template>
@@ -86,11 +190,11 @@
<style scoped lang="scss">
.homeRightSelect {
  width: 356px;
  :deep() {
    .el-select__wrapper {
      background: linear-gradient(90deg, #195bad 0%, rgba(25, 91, 173, 0) 100%);
      min-height: 28px;
      height: 28px;
      box-shadow: none;
      border: 1px solid #306fca;
    }
@@ -98,6 +202,7 @@
    .el-select__placeholder {
      font-family: Microsoft YaHei, Microsoft YaHei, serif;
      color: #ffffff;
      font-size: 14px;
    }
  }
}
@@ -118,6 +223,11 @@
  display: flex;
  flex-direction: column;
  align-items: center;
  .dateTime{
    width: 356px;
    margin: 15px 0 8px 0;
  }
  .overviewData {
    width: 360px;
@@ -189,6 +299,7 @@
    justify-content: space-between;
    width: 356px;
    height: 23px;
    margin-top: 16px;
    &--left-img {
      width: 16px;
@@ -210,5 +321,10 @@
      opacity: 0.2;
    }
  }
  .chart {
    width: 356px;
    height: 190px;
  }
}
</style>