yangyin
2024-11-20 190529c5038e81b2f5539d3ee9738274e7a63637
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>存销比</title>
        <script src="/customer_list/ch/ai_html/views/demo/js/tailwind.js"></script>
        <script src="/customer_list/ch/ai_html/views/demo/js/vue.global.js"></script>
        <script src="/customer_list/ch/ai_html/views/demo/js/iframe-resizer/child-5.1.5.js" async></script>
        <script src="/customer_list/ch/ai_html/views/demo/js/index.full.js"></script>
        <script src="/customer_list/ch/ai_html/views/demo/js/customInstruction.js"></script>
        <link href="/customer_list/ch/static/fonts/iconfont/iconfont.css" rel="stylesheet" type="text/css" />
        <link href="/customer_list/ch/ai_html/views/demo/css/ele-index.css" rel="stylesheet" type="text/css" />
        <script src="/customer_list/ch/ai_html/views/demo/js/echarts.min.js"></script>
    </head>
 
    <body>
        <div class="w-full h-full bg-[#f2f4f8] px-[5px] py-[5px]" id="stockToUseBoard">
            <div class="bg-[rgb(242,244,248)] space-y-1">
                <div v-resize="chartContainerResize" class="w-full h-full bg-white">
                    <div class="w-full bg-white h-[280px]" id="stockToUseLineChart"></div>
                </div>
            </div>
        </div>
    </body>
    <script>
        const { createApp, onMounted, ref, reactive } = Vue;
        const stockToUseLineChartDomRef = ref(null);
        const App = createApp({
            setup() {
                let state = reactive({
                    stockToUseBoardList: [
                        {
                            ID: 1,
                            stockDate: '2024-4-01',
                            value: 120,
                        },
                        {
                            ID: 2,
                            stockDate: '2024-5-01',
                            value: 70,
                        },
                        {
                            ID: 3,
                            stockDate: '2024-6-01',
                            value: 50,
                        },
                        {
                            ID: 4,
                            stockDate: '2024-7-01',
                            value: 67,
                        },
                        {
                            ID: 5,
                            stockDate: '2024-8-01',
                            value: 74,
                        },
                    ],
 
                    consumptionSurveyList: [
                        {
                            ID: 1,
                            stockDate: '2022-4-01',
                            value: 120,
                        },
                        {
                            ID: 2,
                            stockDate: '2023-5-01',
                            value: 70,
                        },
                        {
                            ID: 3,
                            stockDate: '2024-6-01',
                            value: 50,
                        },
                    ],
                });
                const initStockToUseLineChart = () => {
                    const lineXData = state.stockToUseBoardList.map((item) => item.stockDate.slice(2, 6) + '月');
                    var chartDom = document.getElementById('stockToUseLineChart');
                    var stockToUseBarChartDom = echarts.init(chartDom);
                    stockToUseLineChartDomRef.value = stockToUseBarChartDom;
                    var option = {
                        title: [
                            {
                                text: '周社会存销比',
                                left: 50,
                                top: 10,
                                textStyle: {
                                    fontSize: 20,
                                },
                            },
                        ],
                        grid: {
                            left: 10,
                            right: 40,
                        },
                        legend: {
                            top: 30,
                        },
                        xAxis: {
                            type: 'category',
                            data: lineXData,
                        },
                        yAxis: {
                            show: false,
                        },
 
                        series: [
                            {
                                data: [150, 230, 224, 218, 135],
                                type: 'line',
                                areaStyle: {
                                    color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                                        { offset: 0, color: '#8470FF' },
                                        { offset: 0.5, color: 'rgba(182,229,187,0.3)' },
                                        { offset: 1, color: 'rgba(182,229,187,0.1)' },
                                    ]),
                                },
                                lineStyle: {
                                    color: '#8470FF',
                                    width: 3,
                                },
                                itemStyle: {
                                    color: '#8470FF',
                                },
                                label: {
                                    show: true,
                                    position: 'top', // 顶部显示
                                },
                            },
                        ],
                    };
 
                    option && stockToUseBarChartDom.setOption(option);
                };
                const chartContainerResize = ({ width, height }) => {
                    stockToUseLineChartDomRef.value.resize();
                };
                onMounted(() => {
                    initStockToUseLineChart();
                });
 
                return { state, chartContainerResize };
            },
        });
        App.use(ElementPlus);
        elementResizeDirective(App);
        App.mount('#stockToUseBoard');
    </script>
</html>