forked from drone/command-center-dashboard

chenyao
2025-03-28 2792c95710da351547c85cc21ee82b233c5bec83
src/views/Home/components/HomeLeft/InspectionRaskDetails.vue
@@ -13,11 +13,16 @@
               </div>
            </div>
        </div>
        <CommonDateTime></CommonDateTime>
        <div class="chart-container" ref="chartRef"></div>
    </div>
</template>
<script setup>
import { hToV, wToR } from '@/utils/pxConver';
import * as echarts from 'echarts';
import CommonDateTime from '@/components/CommonDateTime.vue';
// import { ref, onMounted } from 'vue';
const list = ref([
  { name: '计划执行', value: 89, color: '#FFFFFF' },
@@ -27,6 +32,86 @@
  { name: '执行失败', value: 10, color: '#FF8E8E' },
]);
const chartRef = ref(null);
onMounted(() => {
    const chart = echarts.init(chartRef.value);
    const option = {
        grid: {
            top: '15%',
            left: '3%',
            right: '4%',
            bottom: '3%',
            containLabel: true
        },
        tooltip: {
            trigger: 'axis',
            backgroundColor: 'rgba(0,0,0,0.7)',
            borderColor: '#0070FF',
            borderWidth: 1,
            textStyle: {
                color: '#fff'
            },
            formatter: '{b}日: {c}次'
        },
        xAxis: {
            type: 'category',
            data: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10',
                   '11', '12', '13', '14', '15', '16', '17', '18', '19',
                   '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30'],
            axisLine: {
                show: false  // 隐藏轴线
            },
            axisTick: {
                show: true,
                length: 2,
                lineStyle: {
                    color: '#ffffff'
                }
            },
            axisLabel: {
                color: '#ffffff',
                margin: 8
            }
        },
        yAxis: {
            type: 'value',
            axisLine: {
                lineStyle: {
                    color: '#ffffff'
                }
            },
            axisLabel: {
                color: '#ffffff'
            },
            splitLine: {
                lineStyle: {
                    color: 'rgba(255, 255, 255, 0.1)'
                }
            }
        },
        series: [{
            data: [10, 15, 8, 20, 12, 18, 15, 22, 16, 19,
                   14, 17, 21, 13, 16, 18, 15, 20, 17, 22,
                   19, 16, 14, 18, 21, 15, 17, 20, 16, 18],
            type: 'bar',
            barWidth: '60%',
            itemStyle: {
                color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                    { offset: 0, color: '#1EE7E7' },
                    { offset: 1, color: 'rgba(0, 112, 255, 0.1)' }
                ])
            }
        }]
    };
    chart.setOption(option);
    // 监听窗口大小变化
    window.addEventListener('resize', () => {
        chart.resize();
    });
});
</script>
<style scoped lang="scss">
@@ -50,7 +135,9 @@
            font-weight: 500;
            font-size: 14px;
            color: #FFFFFF;
            font-family: Source Han Sans CN, Source Han Sans CN;
            .value {
                font-family: YouSheBiaoTiHei, YouSheBiaoTiHei;
                margin-left: 8px;
                font-size: 26px;
            }
@@ -67,16 +154,22 @@
            line-height: hToV(22);
            padding: 0 10px 10px 0;
            .name {
                font-family: Source Han Sans CN, Source Han Sans CN;
                font-weight: 400;
                font-size: 14px;
                color: #FFFFFF;
            }
            .value {
                font-family: Source Han Sans CN, Source Han Sans CN;
                font-family: YouSheBiaoTiHei, YouSheBiaoTiHei;
                font-weight: 400;
                font-size: 26px;
            }
        }
    }
    .chart-container {
        width: 100%;
        height: 200px;
        margin-top: 20px;
    }
}
</style>