feat: 构建泡泡玛特相关图表

This commit is contained in:
Joey
2026-08-23 21:23:41 +08:00
commit 3ae396776d
31 changed files with 3454 additions and 0 deletions
+64
View File
@@ -0,0 +1,64 @@
import { col } from '../csv.js';
import {
PALETTE, FONT, axisCommon, categoryAxis, titleStyle, legendStyle,
lineSeries, footnote, watermarks, LAYOUT,
} from '../theme.js';
/**
* 图 3:毛利率 vs 非国际净利率,两条线的简版对照
* 从 margin.csv 复用同一份数据,只挑两列
*/
export function twoLineChart(rows, { width, height }) {
return {
backgroundColor: '#fff',
title: { ...titleStyle, text: '毛利率与非国际净利率(半年与年度)' },
legend: {
...legendStyle,
top: LAYOUT.legendTop,
data: ['毛利率', '非国际归母净利率'].map(name => ({
name,
icon: 'emptyCircle', // 全部折线图
})),
},
grid: { left: 72, right: 48, top: LAYOUT.gridTop, bottom: 62 },
tooltip: {
trigger: 'axis',
valueFormatter: (v) => `${v}%`,
textStyle: { fontFamily: FONT },
},
xAxis: { ...categoryAxis, data: col(rows, 'period') },
yAxis: {
...axisCommon,
type: 'value',
name: '比率(%',
nameLocation: 'middle',
nameGap: 46,
nameTextStyle: { color: PALETTE.grey, fontSize: 13, fontFamily: FONT },
min: -5,
max: 80,
interval: 25,
axisLabel: { ...axisCommon.axisLabel, formatter: '{value}%' },
},
series: [
lineSeries({
name: '毛利率',
data: col(rows, 'gross_margin'),
color: PALETTE.navy,
labelPosition: 'top',
formatter: (p) => `${p.value}%`,
width: 3.5,
}),
lineSeries({
name: '非国际归母净利率',
data: col(rows, 'non_gaap_net_margin'),
color: PALETTE.coral,
labelPosition: 'top',
formatter: (p) => `${p.value}%`,
}),
],
graphic: [
...watermarks(width, height),
footnote('示例数据 | @思考的Joey'),
],
};
}