89 lines
2.8 KiB
JavaScript
89 lines
2.8 KiB
JavaScript
import { col } from '../csv.js';
|
||
import {
|
||
CHANNEL_COLORS, PALETTE, FONT, axisCommon, standalonePeriodAxis, titleStyle, legendStyle,
|
||
financialViewDisclosure, financialViewLabel,
|
||
lineSeries, footnote, watermarks, LAYOUT,
|
||
} from '../theme.js';
|
||
|
||
/** 泡泡玛特渠道收入结构与增速。 */
|
||
export function channelRevenueChart(rows, { width, height, view = 'all' }) {
|
||
const channels = [
|
||
{ key: 'retail', name: '零售店', color: CHANNEL_COLORS.retail },
|
||
{ key: 'online', name: '线上', color: CHANNEL_COLORS.online },
|
||
{ key: 'robot_store', name: '机器人商店', color: CHANNEL_COLORS.robotStore },
|
||
{ key: 'wholesale', name: '批发', color: CHANNEL_COLORS.wholesale },
|
||
];
|
||
|
||
return {
|
||
backgroundColor: '#fff',
|
||
title: {
|
||
...titleStyle,
|
||
text: `泡泡玛特渠道收入结构与增速(${financialViewLabel(view)})`,
|
||
subtext: ['渠道收入为堆叠柱;折线为营业收入同比增速', financialViewDisclosure(view)].filter(Boolean).join('\n'),
|
||
},
|
||
legend: {
|
||
...legendStyle,
|
||
top: LAYOUT.legendTop,
|
||
data: [...channels.map((item) => item.name), '营业收入同比'],
|
||
},
|
||
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: col(rows, 'period') },
|
||
yAxis: [
|
||
{
|
||
...axisCommon,
|
||
type: 'value',
|
||
name: '渠道收入(亿元)',
|
||
nameLocation: 'middle',
|
||
nameGap: 56,
|
||
nameTextStyle: { color: PALETTE.grey, fontSize: 13, fontFamily: FONT },
|
||
min: 0,
|
||
},
|
||
{
|
||
...axisCommon,
|
||
type: 'value',
|
||
name: '营业收入同比(%)',
|
||
nameLocation: 'middle',
|
||
nameGap: 60,
|
||
nameRotate: -90,
|
||
nameTextStyle: { color: PALETTE.grey, fontSize: 13, fontFamily: FONT },
|
||
min: 0,
|
||
max: 250,
|
||
interval: 50,
|
||
axisLabel: { ...axisCommon.axisLabel, formatter: '{value}%' },
|
||
splitLine: { show: false },
|
||
},
|
||
],
|
||
series: [
|
||
...channels.map((item) => ({
|
||
name: item.name,
|
||
type: 'bar',
|
||
stack: 'channel-revenue',
|
||
data: col(rows, item.key),
|
||
itemStyle: { color: item.color },
|
||
emphasis: { focus: 'series' },
|
||
})),
|
||
{
|
||
...lineSeries({
|
||
name: '营业收入同比',
|
||
data: col(rows, 'revenue_yoy'),
|
||
color: CHANNEL_COLORS.revenueGrowth,
|
||
formatter: (p) => `${p.value.toFixed(0)}%`,
|
||
width: 3,
|
||
}),
|
||
yAxisIndex: 1,
|
||
z: 10,
|
||
},
|
||
],
|
||
graphic: [
|
||
...watermarks(width, height),
|
||
footnote('数据来源:泡泡玛特营收构成表;渠道口径按财报披露 | @思考的Joey'),
|
||
],
|
||
};
|
||
}
|