gaoluyang
2026-06-24 712aa51536236d43e87273e4ce45ac5691dffad8
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
/** 商品统计折线图配置 */
export function getProductSummaryChartOptions(data: any[]): any {
  // 处理数据:将金额从分转换为元
  const processedData = data.map((item) => ({
    ...item,
    orderPayPrice: Number((item.orderPayPrice / 100).toFixed(2)),
    afterSaleRefundPrice: Number((item.afterSaleRefundPrice / 100).toFixed(2)),
  }));
 
  return {
    dataset: {
      dimensions: [
        'time',
        'browseCount',
        'browseUserCount',
        'orderPayPrice',
        'afterSaleRefundPrice',
      ],
      source: processedData,
    },
    grid: {
      left: 20,
      right: 20,
      bottom: 20,
      top: 80,
      containLabel: true,
    },
    legend: {
      top: 50,
    },
    series: [
      {
        name: '商品浏览量',
        type: 'line',
        smooth: true,
        itemStyle: { color: '#B37FEB' },
      },
      {
        name: '商品访客数',
        type: 'line',
        smooth: true,
        itemStyle: { color: '#FFAB2B' },
      },
      {
        name: '支付金额',
        type: 'bar',
        smooth: true,
        yAxisIndex: 1,
        itemStyle: { color: '#1890FF' },
      },
      {
        name: '退款金额',
        type: 'bar',
        smooth: true,
        yAxisIndex: 1,
        itemStyle: { color: '#00C050' },
      },
    ],
    toolbox: {
      feature: {
        // 数据区域缩放
        dataZoom: {
          yAxisIndex: false, // Y轴不缩放
        },
        brush: {
          type: ['lineX', 'clear'], // 区域缩放按钮、还原按钮
        },
        saveAsImage: {
          show: true,
          name: '商品状况',
        }, // 保存为图片
      },
    },
    tooltip: {
      trigger: 'axis',
      axisPointer: {
        type: 'cross',
      },
      padding: [5, 10],
    },
    xAxis: {
      type: 'category',
      boundaryGap: true,
      axisTick: {
        show: false,
      },
    },
    yAxis: [
      {
        type: 'value',
        name: '金额',
        axisLine: {
          show: false,
        },
        axisTick: {
          show: false,
        },
        axisLabel: {
          color: '#7F8B9C',
        },
        splitLine: {
          show: true,
          lineStyle: {
            color: '#F5F7F9',
          },
        },
      },
      {
        type: 'value',
        name: '数量',
        axisLine: {
          show: false,
        },
        axisTick: {
          show: false,
        },
        axisLabel: {
          color: '#7F8B9C',
        },
        splitLine: {
          show: true,
          lineStyle: {
            color: '#F5F7F9',
          },
        },
      },
    ],
  };
}