96 lines
3.4 KiB
JavaScript
96 lines
3.4 KiB
JavaScript
import { col } from '../csv.js';
|
||
import {
|
||
FINANCIAL_COLORS, PALETTE, FONT, axisCommon, standalonePeriodAxis, titleStyle, legendStyle,
|
||
financialViewDisclosure, financialViewLabel,
|
||
lineSeries, footnote, watermarks, LAYOUT,
|
||
} from '../theme.js';
|
||
|
||
/** 泡泡玛特经营现金流与净利润:观察利润的现金兑现能力。 */
|
||
export function cashConversionChart(rows, { width, height, view = 'all' }) {
|
||
const periods = col(rows, 'period');
|
||
const conversionMax = Math.max(...col(rows, 'cash_conversion').filter(Number.isFinite));
|
||
const conversionAxisMax = Math.max(200, Math.ceil((conversionMax * 1.1) / 100) * 100);
|
||
const barWidth = view === 'all' ? 14 : view === 'halfyear' ? 24.96 : 31.2;
|
||
|
||
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 },
|
||
valueFormatter: (value) => `${value.toFixed(1)}`,
|
||
},
|
||
xAxis: { ...standalonePeriodAxis, data: periods },
|
||
yAxis: [
|
||
{
|
||
...axisCommon,
|
||
type: 'value',
|
||
name: '金额(亿元)',
|
||
nameLocation: 'middle',
|
||
nameGap: 52,
|
||
nameTextStyle: { color: PALETTE.grey, fontSize: 13, fontFamily: FONT },
|
||
min: 0,
|
||
splitLine: { show: true, lineStyle: { color: PALETTE.gridLine } },
|
||
},
|
||
{
|
||
...axisCommon,
|
||
type: 'value',
|
||
name: '现金转换率(%)',
|
||
nameLocation: 'middle',
|
||
nameGap: 58,
|
||
nameRotate: -90,
|
||
nameTextStyle: { color: PALETTE.grey, fontSize: 13, fontFamily: FONT },
|
||
min: 0,
|
||
max: conversionAxisMax,
|
||
interval: conversionAxisMax / 4,
|
||
axisLabel: { ...axisCommon.axisLabel, formatter: '{value}%' },
|
||
splitLine: { show: false },
|
||
},
|
||
],
|
||
series: [
|
||
{
|
||
name: '经营活动现金流净额',
|
||
type: 'bar',
|
||
data: col(rows, 'operating_cash_flow'),
|
||
barWidth,
|
||
itemStyle: { color: FINANCIAL_COLORS.operatingCashFlow },
|
||
label: { show: true, position: 'top', color: PALETTE.ink, fontFamily: FONT, fontSize: 11, formatter: (p) => p.value.toFixed(1) },
|
||
},
|
||
{
|
||
name: '净利润',
|
||
type: 'bar',
|
||
data: col(rows, 'net_profit'),
|
||
barWidth,
|
||
itemStyle: { color: FINANCIAL_COLORS.netProfit },
|
||
label: { show: true, position: 'top', color: PALETTE.ink, fontFamily: FONT, fontSize: 11, formatter: (p) => p.value.toFixed(1) },
|
||
},
|
||
{
|
||
...lineSeries({
|
||
name: '现金转换率',
|
||
data: col(rows, 'cash_conversion'),
|
||
color: FINANCIAL_COLORS.cashConversion,
|
||
formatter: (p) => `${p.value.toFixed(0)}%`,
|
||
width: 3,
|
||
}),
|
||
yAxisIndex: 1,
|
||
z: 10,
|
||
},
|
||
],
|
||
graphic: [
|
||
...watermarks(width, height),
|
||
footnote('数据来源:泡泡玛特合并现金流量表、利润表;H2为单独半年 | @思考的Joey'),
|
||
],
|
||
};
|
||
}
|