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
| import type { MallTradeStatisticsApi } from '#/api/mall/statistics/trade';
|
| import { fenToYuan } from '../../../../../packages/utils/src';
|
| /** 交易趋势折线图配置 */
| export function getTradeTrendChartOptions(
| data: MallTradeStatisticsApi.TradeTrendSummaryRespVO[],
| ): any {
| // 处理数据:将分转换为元
| const processedData = data.map((item) => ({
| ...item,
| turnoverPrice: Number(fenToYuan(item.turnoverPrice)),
| orderPayPrice: Number(fenToYuan(item.orderPayPrice)),
| rechargePrice: Number(fenToYuan(item.rechargePrice)),
| expensePrice: Number(fenToYuan(item.expensePrice)),
| }));
|
| return {
| dataset: {
| dimensions: [
| 'date',
| 'turnoverPrice',
| 'orderPayPrice',
| 'rechargePrice',
| 'expensePrice',
| ],
| source: processedData,
| },
| grid: {
| left: 20,
| right: 20,
| bottom: 20,
| top: 80,
| containLabel: true,
| },
| legend: {
| top: 50,
| },
| series: [
| {
| name: '营业额',
| type: 'line',
| smooth: true,
| itemStyle: { color: '#1890FF' },
| },
| {
| name: '商品支付金额',
| type: 'line',
| smooth: true,
| itemStyle: { color: '#722ED1' },
| },
| {
| name: '充值金额',
| type: 'line',
| smooth: true,
| itemStyle: { color: '#FAAD14' },
| },
| {
| name: '支出金额',
| type: 'line',
| smooth: true,
| itemStyle: { color: '#52C41A' },
| },
| ],
| toolbox: {
| feature: {
| // 数据区域缩放
| dataZoom: {
| yAxisIndex: false, // Y轴不缩放
| },
| brush: {
| type: ['lineX', 'clear'], // 区域缩放按钮、还原按钮
| },
| saveAsImage: {
| show: true,
| name: '交易状况',
| }, // 保存为图片
| },
| },
| tooltip: {
| trigger: 'axis',
| axisPointer: {
| type: 'cross',
| },
| padding: [5, 10],
| formatter(params: any) {
| let result = `<div><strong>${params[0].data.time}</strong></div>`;
| params.forEach((item: any) => {
| result += `<div style="margin: 4px 0;">
| <span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:${item.color};"></span>
| ${item.seriesName}: ¥${item.data[item.dimensionNames[item.encode.y[0]]]}
| </div>`;
| });
| return result;
| },
| },
| xAxis: {
| type: 'category',
| boundaryGap: false,
| axisTick: {
| show: false,
| },
| },
| yAxis: {
| type: 'value',
| axisLine: {
| show: false,
| },
| axisTick: {
| show: false,
| },
| axisLabel: {
| formatter: '¥{value}',
| color: '#7F8B9C',
| },
| splitLine: {
| show: true,
| lineStyle: {
| color: '#F5F7F9',
| },
| },
| },
| };
| }
|
|