fuchengshen
2022-06-28 2425be3bdfce9480536733eba5977ee2c942d7a4
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<template>
    <div class="tab-chart">
        <div class="tab-chart__header">
            <ul class="tab-chart__tab">
                <li class="active">销售额</li>
                <li>访问量</li>
            </ul>
 
            <span class="tab-chart__year">2020</span>
        </div>
 
        <div class="tab-chart__container">
            <v-chart :option="chartOption" autoresize />
        </div>
    </div>
</template>
 
<script lang="ts">
import { defineComponent, reactive } from "vue";
import { isPc } from "/@/cool/utils";
 
export default defineComponent({
    setup() {
        const barWidth = isPc() ? 25 : 15;
        const chartOption = reactive<any>({
            grid: {
                top: "20px",
                bottom: "30px",
                right: "10px",
                containLabel: true
            },
            xAxis: {
                type: "category",
                data: [],
                offset: 5,
                axisLine: {
                    show: false
                },
                axisTick: {
                    show: false
                }
            },
            yAxis: {
                type: "value",
                offset: 20,
                splitLine: {
                    show: false
                },
                axisTick: {
                    show: false
                },
                axisLine: {
                    show: false
                }
            },
            tooltip: {
                trigger: "axis",
                formatter: (comp: any) => {
                    const [serie] = comp;
 
                    return `${serie.seriesName}:${serie.value}`;
                },
                axisPointer: {
                    show: true,
                    status: "shadow",
                    z: -1,
                    shadowStyle: {
                        color: "#E6F7FF"
                    },
                    type: "shadow"
                },
                extraCssText: "width:120px; white-space:pre-wrap"
            },
            series: [
                {
                    barWidth,
                    name: "付款笔数",
                    type: "bar",
                    data: [],
                    itemStyle: {
                        normal: {
                            color: "#4165d7"
                        }
                    }
                },
                {
                    type: "bar",
                    barWidth,
                    xAxisIndex: 0,
                    barGap: "-100%",
                    data: [],
                    itemStyle: {
                        normal: {
                            color: "#f1f1f9"
                        }
                    },
                    zlevel: -1
                }
            ]
        });
 
        chartOption.xAxis.data = new Array(12).fill(1).map((e, i) => i + 1 + "月");
        chartOption.series[0].data = new Array(12)
            .fill(1)
            .map(() => parseInt(String(Math.random() * 100)));
        chartOption.series[1].data = new Array(12).fill(100);
 
        return {
            chartOption
        };
    },
    data() {
        return {};
    }
});
</script>
 
<style lang="scss" scoped>
.tab-chart {
    &__header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        height: 50px;
        padding: 0 20px;
 
        ul {
            li {
                list-style: none;
                float: left;
                margin-right: 20px;
                font-size: 15px;
                color: #dbdbdb;
                cursor: pointer;
 
                &.active {
                    color: #000;
                    font-weight: bold;
                }
            }
        }
    }
 
    &__year {
        font-size: 14px;
        position: relative;
 
        &::before {
            display: block;
            content: "";
            height: 8px;
            width: 8px;
            border-radius: 8px;
            background-color: #000;
            position: absolute;
            left: -15px;
            top: 4px;
        }
    }
 
    &__container {
        height: 300px;
        padding: 0 15px;
 
        .echarts {
            height: 100%;
            width: 100%;
        }
    }
}
</style>