<template>
    <v-chart :option="options" theme="dark" style="width: 100%;height: 100%;" />
</template>

<script setup>
import { computed } from 'vue';
const prop = defineProps({
    data: {
        type: Object,
        default: () => {
            return {};
        }
    }
});

const options = computed(() => {
    return {
        tooltip: {
            trigger: 'axis',
            backgroundColor: 'rgba(0, 0, 0, 0.8)',
            borderColor: '#00c6ff',
            borderWidth: 2,
            textStyle: {
                color: '#fff',
                fontSize: 14
            },
            formatter: function (params) {
                let tooltipText = '';
                let xAxisValue = params[0].name;
                params.forEach((item) => {
                    tooltipText += `<div style="padding: 2px 0;"><strong>${item.seriesName}:</strong> ${item.value}</div>`;
                });
                return `${xAxisValue}<br>${tooltipText}`;
            },
            padding: 10,
            extraCssText: 'border-radius: 8px; box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);'
        },
        backgroundColor: 'transparent',
        legend: {
            show: true,
            data: ['目标产量', '实际产量'],
            textStyle: {
                color: '#fff',

            },
        },
        xAxis: {
            type: 'category',
            data: ['102410', '102411', '102412', '102413', '102414', '102415', '102416', '102417'],
            axisLabel: {
                color: "#ffffff",
                interval: 0,
            },
            axisLine: {
                lineStyle: {
                    color: '#0091ea'
                }
            },
            axisTick: {
                show: false,
            }
        },
        yAxis: [
            {
                type: 'value',
                axisTick: {
                    show: false
                }
            },
            {
                type: 'value',
                axisTick: {
                    show: false
                }
            }
        ],
        series: [
            {
                name: '目标产量',
                data: [150, 105, 110, 80, 120, 100, 140, 180],
                yAxisIndex: 0,
                type: 'bar',
                barCategoryGap: '10%',
                showBackground: true,
                itemStyle: {
                    color: {
                        type: 'linear',
                        x: 0,
                        y: 0,
                        x2: 1,
                        y2: 1,
                        colorStops: [
                            { offset: 0, color: '#5aaef3' },
                            { offset: 1, color: '#1e90ff' }
                        ]
                    },
                    borderRadius: [60, 60, 60, 60],
                    stroke: '#00c6ff',
                    lineWidth: 2
                },
                label: {
                    show: true,
                    position: 'top',
                    color: '#ffffff'
                },
                backgroundStyle: {
                    borderRadius: [60, 60, 60, 60],
                }
            },
            {
                name: '实际产量',
                yAxisIndex: 1,
                data: [106, 90, 25, 80, 35, 100, 140, 172],
                type: 'bar',
                barCategoryGap: '10%',
                showBackground: true,
                itemStyle: {
                    color: {
                        type: 'linear',
                        x: 0,
                        y: 0,
                        x2: 1,
                        y2: 1,
                        colorStops: [
                            { offset: 0, color: '#f8efd4' },
                            { offset: 1, color: '#fbdc7f' }
                        ]
                    },
                    borderRadius: [60, 60, 60, 60],
                    stroke: '#ff6347',
                    lineWidth: 2
                },
                label: {
                    show: true,
                    position: 'top',
                    color: '#ffffff'
                },
                backgroundStyle: {
                    borderRadius: [60, 60, 60, 60],
                }
            },
        ],
    }
});
</script>

<style lang="scss" scoped></style>