import { col } from '../csv.js'; import { PALETTE, FONT, axisCommon, standalonePeriodAxis, titleStyle, legendStyle, financialViewDisclosure, financialViewLabel, lineSeries, footnote, watermarks, LAYOUT, } from '../theme.js'; /** * 泡泡玛特盈利能力分析图 * 柱状图展示收入和利润,折线图展示毛利率 */ export function profitChart(rows, { width, height, view = 'all' }) { const periods = col(rows, 'period'); const revenue = col(rows, 'revenue'); const grossProfit = col(rows, 'gross_profit'); const netProfit = col(rows, 'net_profit'); const grossMargin = col(rows, 'gross_margin'); return { backgroundColor: '#fff', title: { ...titleStyle, text: `泡泡玛特盈利能力分析(${financialViewLabel(view)})`, subtext: ['营收、毛利、净利润及毛利率变化', financialViewDisclosure(view)].filter(Boolean).join('\n'), }, legend: { ...legendStyle, top: LAYOUT.legendTop, data: ['营业收入', '毛利润', '归母净利润', '毛利率'], }, grid: { left: 78, right: 82, top: LAYOUT.gridTop, bottom: 90 }, tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' }, textStyle: { fontFamily: FONT }, }, xAxis: { ...standalonePeriodAxis, 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('数据来源:泡泡玛特财报;H2为单独半年 | @Joey知行记'), ], }; }