import { col } from '../csv.js'; import { PALETTE, FONT, axisCommon, periodAxis, titleStyle, legendStyle, lineSeries, footnote, watermarks, LAYOUT, } from '../theme.js'; /** * 泡泡玛特盈利能力分析图 * 柱状图展示收入和利润,折线图展示毛利率 */ export function profitChart(rows, { width, height }) { const periods = col(rows, 'period').reverse(); // 按时间正序 const revenue = col(rows, 'revenue').reverse(); const grossProfit = col(rows, 'gross_profit').reverse(); const netProfit = col(rows, 'net_profit').reverse(); const grossMargin = col(rows, 'gross_margin').reverse(); return { backgroundColor: '#fff', title: { ...titleStyle, text: '泡泡玛特盈利能力分析(2022H2-2026H1)', subtext: '营收、毛利、净利润及毛利率变化', }, legend: { ...legendStyle, top: LAYOUT.legendTop, data: [ { name: '营业收入', icon: 'rect' }, { name: '毛利润', icon: 'rect' }, { name: '归母净利润', icon: 'rect' }, { name: '毛利率', icon: 'emptyCircle' }, ], }, grid: { left: 78, right: 82, top: LAYOUT.gridTop, bottom: 90 }, tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' }, textStyle: { fontFamily: FONT }, }, xAxis: { ...periodAxis, data: periods }, yAxis: [ { ...axisCommon, type: 'value', name: '金额(亿元)', nameLocation: 'middle', nameGap: 52, nameTextStyle: { color: PALETTE.grey, fontSize: 13, fontFamily: FONT }, min: 0, max: 400, interval: 100, }, { ...axisCommon, type: 'value', name: '毛利率(%)', nameLocation: 'middle', nameGap: 58, nameRotate: -90, nameTextStyle: { color: PALETTE.grey, fontSize: 13, fontFamily: FONT }, min: 55, max: 75, interval: 5, axisLabel: { ...axisCommon.axisLabel, formatter: '{value}%', }, splitLine: { show: false }, }, ], series: [ { name: '营业收入', type: 'bar', data: revenue, barWidth: 18, itemStyle: { color: PALETTE.navy }, label: { show: true, position: 'top', color: PALETTE.ink, fontSize: 11, fontFamily: FONT, }, }, { name: '毛利润', type: 'bar', data: grossProfit, barWidth: 18, itemStyle: { color: PALETTE.sage }, label: { show: true, position: 'top', color: PALETTE.ink, fontSize: 11, fontFamily: FONT, }, }, { name: '归母净利润', type: 'bar', data: netProfit, barWidth: 18, itemStyle: { color: PALETTE.orange }, label: { show: true, position: 'top', color: PALETTE.ink, fontSize: 11, fontFamily: FONT, }, }, { ...lineSeries({ name: '毛利率', data: grossMargin, color: PALETTE.red, labelPosition: 'top', formatter: (p) => `${p.value.toFixed(1)}%`, width: 3, }), yAxisIndex: 1, z: 10, }, ], graphic: [ ...watermarks(width, height), footnote('数据来源:泡泡玛特财报(累计数据)| @思考的Joey'), ], }; }