import type { MallTradeStatisticsApi } from '#/api/mall/statistics/trade'; import { fenToYuan } from '@vben/utils'; /** 交易趋势折线图配置 */ 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 = `