style: usage chart

This commit is contained in:
jialin
2026-06-06 14:29:49 +08:00
committed by jialin
parent 4a86b71018
commit eab7d9c77f
3 changed files with 23 additions and 9 deletions
+1 -1
View File
@@ -126,7 +126,7 @@ const BarChart: React.FC<BarChartProps> = (props) => {
left: 0, left: 0,
right: 0, right: 0,
top: title ? 30 : 10, top: title ? 30 : 10,
bottom: 28, bottom: 0,
containLabel: true containLabel: true
}, },
tooltip: { tooltip: {
+15 -2
View File
@@ -45,12 +45,20 @@ const PieChart: React.FC<PieChartProps> = ({
const options = useMemo( const options = useMemo(
() => ({ () => ({
color: colors, color: colors,
grid: {
left: 0,
right: 0,
top: 0,
bottom: 0,
containLabel: true
},
tooltip: { tooltip: {
trigger: 'item', trigger: 'item',
position: 'top',
// Keep the tooltip inside the chart box — the donut sits on the left, so // Keep the tooltip inside the chart box — the donut sits on the left, so
// a left-slice tooltip could otherwise spill out and get hidden behind // a left-slice tooltip could otherwise spill out and get hidden behind
// the side menu. // the side menu.
confine: true, confine: false,
backgroundColor: token.colorBgElevated, backgroundColor: token.colorBgElevated,
borderColor: 'transparent', borderColor: 'transparent',
formatter: (params: any) => { formatter: (params: any) => {
@@ -97,7 +105,12 @@ const PieChart: React.FC<PieChartProps> = ({
// No on-arc label — the percentage lives in the tooltip instead, so // No on-arc label — the percentage lives in the tooltip instead, so
// hovering shows value + percent in one place. // hovering shows value + percent in one place.
label: { show: false }, label: { show: false },
emphasis: { label: { show: false }, scale: false }, emphasis: {
label: {
show: false
},
scale: true
},
labelLine: { show: false }, labelLine: { show: false },
data data
} }
+7 -6
View File
@@ -25,8 +25,9 @@ import useCoolColors from '@/hooks/use-cool-colors';
import BarChart from '@/pages/_components/bar-chart'; import BarChart from '@/pages/_components/bar-chart';
import PieChart from '@/pages/_components/pie-chart'; import PieChart from '@/pages/_components/pie-chart';
import { formatLargeNumber } from '@/utils'; import { formatLargeNumber } from '@/utils';
import { CardWrapper } from '@gpustack/core-ui';
import { useAccess, useIntl } from '@umijs/max'; import { useAccess, useIntl } from '@umijs/max';
import { Card, Col, Empty, Row } from 'antd'; import { Col, Empty, Row } from 'antd';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import React, { useEffect, useMemo, useState } from 'react'; import React, { useEffect, useMemo, useState } from 'react';
import { queryUsageTimeSeriesData } from '../apis'; import { queryUsageTimeSeriesData } from '../apis';
@@ -128,7 +129,7 @@ const DomainSection: React.FC<{
/> />
); );
return ( return (
<Card variant="borderless" styles={{ body: { padding: 16 } }}> <CardWrapper style={{ paddingBlock: 16 }}>
<div <div
style={{ style={{
display: 'flex', display: 'flex',
@@ -185,7 +186,7 @@ const DomainSection: React.FC<{
{ name: trendTitle, data: trendData, color: trendColor } { name: trendTitle, data: trendData, color: trendColor }
]} ]}
xAxisData={trendXAxis} xAxisData={trendXAxis}
height={170} height={180}
title={trendTitle} title={trendTitle}
labelFormatter={trendLabel(trendGran)} labelFormatter={trendLabel(trendGran)}
tooltipValueFormatter={(v) => tooltipValueFormatter={(v) =>
@@ -195,7 +196,7 @@ const DomainSection: React.FC<{
)} )}
</div> </div>
</div> </div>
</Card> </CardWrapper>
); );
}; };
@@ -384,9 +385,9 @@ const SummaryTab: React.FC = () => {
onUsersChange={setSelectedUsers} onUsersChange={setSelectedUsers}
onRefresh={() => setRefreshKey((k) => k + 1)} onRefresh={() => setRefreshKey((k) => k + 1)}
/> />
<div style={{ height: 16 }} /> <div style={{ height: 24 }} />
<Row gutter={[0, 12]}> <Row gutter={[0, 24]}>
<Col span={24}> <Col span={24}>
<DomainSection <DomainSection
title={t('usage.metric.tokens')} title={t('usage.metric.tokens')}