style: top users chart compact

This commit is contained in:
jialin
2025-06-27 17:26:34 +08:00
parent d26ea28028
commit bf8e988488
2 changed files with 15 additions and 3 deletions
+9 -2
View File
@@ -5,7 +5,7 @@ import _ from 'lodash';
import React, { memo, useMemo } from 'react'; import React, { memo, useMemo } from 'react';
import { ChartProps } from './types'; import { ChartProps } from './types';
const BarChart: React.FC<ChartProps> = (props) => { const BarChart: React.FC<ChartProps & { maxItems?: number }> = (props) => {
const { const {
seriesData, seriesData,
xAxisData, xAxisData,
@@ -13,6 +13,7 @@ const BarChart: React.FC<ChartProps> = (props) => {
width, width,
labelFormatter, labelFormatter,
legendData, legendData,
maxItems,
title title
} = props; } = props;
const { const {
@@ -30,7 +31,13 @@ const BarChart: React.FC<ChartProps> = (props) => {
...titleConfig, ...titleConfig,
left: 'start' left: 'start'
}, },
grid, grid: {
...grid,
top: 0,
bottom: maxItems
? `${(1 / maxItems) * (maxItems - xAxisData.length) * 100}%`
: 0
},
tooltip: { tooltip: {
...tooltip ...tooltip
}, },
@@ -11,7 +11,12 @@ const TopUser: React.FC<TopUserProps> = (props) => {
return ( return (
<CardWrapper> <CardWrapper>
<HBar seriesData={userData} xAxisData={topUserList} height={440}></HBar> <HBar
seriesData={userData}
xAxisData={topUserList}
height={440}
maxItems={10}
></HBar>
</CardWrapper> </CardWrapper>
); );
}; };