yangyin
2024-10-29 5cb1b28d760e268a9e0bdb96843a654c240915b6
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
<!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="activateCustomerLineChart"></div>
                </div>
            </div>
        </div>
    </body>
    <script>
        const { createApp, onMounted, ref, reactive } = Vue;
        const activateCustomerLineChartDomRef = ref(null);
        const App = createApp({
            setup() {
                let state = reactive({
                    activateCustomerList: [
                        {
                            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,
                        },
                    ],
                });
                const initActivateCustomerLineChart = () => {
                    const lineXData = state.activateCustomerList.map((item) => item.stockDate);
                    var chartDom = document.getElementById('activateCustomerLineChart');
                    var activateCustomerChartDom = echarts.init(chartDom);
                    activateCustomerLineChartDomRef.value = activateCustomerChartDom;
                    let option = {
                        title: [
                            {
                                text: '激活客户数',
                                left: 50,
                                top: 10,
                                textStyle: {
                                    fontSize: 20,
                                },
                            },
                        ],
                        tooltip: {
                            trigger: 'axis',
                        },
                        legend: {
                            top: 20,
                            data: ['PV(访问次数)', 'UV(访问次数)'],
                        },
                        grid: {
                            left: '3%',
                            right: '4%',
                            bottom: '3%',
                            containLabel: true,
                        },
                        toolbox: {
                            feature: {
                                saveAsImage: {},
                            },
                        },
                        xAxis: {
                            type: 'category',
                            boundaryGap: false,
                            data: lineXData,
                        },
                        yAxis: {
                            type: 'value',
                        },
                        series: [
                            {
                                name: 'PV(访问次数)',
                                type: 'line',
                                stack: 'Total',
                                data: [120, 132, 101, 134, 90, 230, 210],
                            },
                            {
                                name: 'UV(访问次数)',
                                type: 'line',
                                stack: 'Total',
                                data: [220, 182, 191, 234, 290, 330, 310],
                            },
                        ],
                    };
                    option && activateCustomerChartDom.setOption(option);
                };
                const chartContainerResize = ({ width, height }) => {
                    activateCustomerLineChartDomRef.value.resize();
                };
                onMounted(() => {
                    initActivateCustomerLineChart();
                });
 
                return { state, chartContainerResize };
            },
        });
        App.use(ElementPlus);
        elementResizeDirective(App);
        App.mount('#stockToUseBoard');
    </script>
</html>