Refactor HistoryDisplay and ModelHistoryDisplay for Improved Layout and Readability
- Reformatted code for better readability by adjusting the structure of the useHistoryLegendOverlay hook. - Updated padding in Card components for consistent layout across displays. - Enhanced Flex components with consistent gap values for improved spacing. - Added overflow handling to div elements to prevent layout issues with chart rows. - Improved loading state handling for better user feedback when no data is available.
This commit is contained in:
parent
3c53278e9f
commit
b212331129
@ -204,8 +204,11 @@ const HistoryDisplay = ({
|
|||||||
})
|
})
|
||||||
}, [config, themeColors])
|
}, [config, themeColors])
|
||||||
|
|
||||||
const { slotRef, measureRef, overlay: legendOverflow } =
|
const {
|
||||||
useHistoryLegendOverlay(seriesLabels)
|
slotRef,
|
||||||
|
measureRef,
|
||||||
|
overlay: legendOverflow
|
||||||
|
} = useHistoryLegendOverlay(seriesLabels)
|
||||||
|
|
||||||
if (!objectType || !config) {
|
if (!objectType || !config) {
|
||||||
return null
|
return null
|
||||||
@ -247,9 +250,9 @@ const HistoryDisplay = ({
|
|||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
style={{ width: '100%' }}
|
style={{ width: '100%' }}
|
||||||
styles={{ body: { padding: '12px', ...styles } }}
|
styles={{ body: { padding: '12px 12px 6px 12px', ...styles } }}
|
||||||
>
|
>
|
||||||
<Flex gap='small' vertical>
|
<Flex gap='12px' vertical>
|
||||||
<Flex style={{ width: '100%' }} justify='space-between' align='center'>
|
<Flex style={{ width: '100%' }} justify='space-between' align='center'>
|
||||||
<Flex align='center' gap='5px' justify='flex-start'>
|
<Flex align='center' gap='5px' justify='flex-start'>
|
||||||
{!startDate && !endDate && (
|
{!startDate && !endDate && (
|
||||||
@ -325,6 +328,7 @@ const HistoryDisplay = ({
|
|||||||
style={{
|
style={{
|
||||||
height: toCssHeight(height),
|
height: toCssHeight(height),
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
|
gap: 12,
|
||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
minHeight: 0
|
minHeight: 0
|
||||||
}}
|
}}
|
||||||
@ -334,8 +338,7 @@ const HistoryDisplay = ({
|
|||||||
style={{
|
style={{
|
||||||
flexShrink: 0,
|
flexShrink: 0,
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
justifyContent: 'center',
|
justifyContent: 'center'
|
||||||
paddingBottom: 4
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<HistoryChartLegend
|
<HistoryChartLegend
|
||||||
@ -344,7 +347,7 @@ const HistoryDisplay = ({
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div style={{ flex: 1, minHeight: 0 }}>
|
<div style={{ flex: 1, minHeight: 0, overflow: 'hidden' }}>
|
||||||
{chartRows.length > 0 && (
|
{chartRows.length > 0 && (
|
||||||
<HistoryEChart
|
<HistoryEChart
|
||||||
chartRows={chartRows}
|
chartRows={chartRows}
|
||||||
@ -355,7 +358,11 @@ const HistoryDisplay = ({
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{loading == false && chartRows.length == 0 && (
|
{loading == false && chartRows.length == 0 && (
|
||||||
<Flex justify='center' align='center' style={{ height: '100%' }}>
|
<Flex
|
||||||
|
justify='center'
|
||||||
|
align='center'
|
||||||
|
style={{ height: '100%', marginBottom: 6 }}
|
||||||
|
>
|
||||||
<MissingPlaceholder message='No data available.' />
|
<MissingPlaceholder message='No data available.' />
|
||||||
</Flex>
|
</Flex>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@ -164,8 +164,11 @@ const ModelHistoryDisplay = ({
|
|||||||
})
|
})
|
||||||
}, [modelStats, themeColors])
|
}, [modelStats, themeColors])
|
||||||
|
|
||||||
const { slotRef, measureRef, overlay: legendOverflow } =
|
const {
|
||||||
useHistoryLegendOverlay(seriesLabels)
|
slotRef,
|
||||||
|
measureRef,
|
||||||
|
overlay: legendOverflow
|
||||||
|
} = useHistoryLegendOverlay(seriesLabels)
|
||||||
|
|
||||||
if (!objectType) {
|
if (!objectType) {
|
||||||
return null
|
return null
|
||||||
@ -371,9 +374,9 @@ const ModelHistoryDisplay = ({
|
|||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
style={{ width: '100%' }}
|
style={{ width: '100%' }}
|
||||||
styles={{ body: { padding: '12px', ...styles } }}
|
styles={{ body: { padding: '12px 12px 6px 12px', ...styles } }}
|
||||||
>
|
>
|
||||||
<Flex gap='small' vertical>
|
<Flex gap='12px' vertical>
|
||||||
<Flex style={{ width: '100%' }} justify='space-between' align='center'>
|
<Flex style={{ width: '100%' }} justify='space-between' align='center'>
|
||||||
<Flex align='center' gap='5px' justify='flex-start'>
|
<Flex align='center' gap='5px' justify='flex-start'>
|
||||||
{!startDate && !endDate && (
|
{!startDate && !endDate && (
|
||||||
@ -434,7 +437,9 @@ const ModelHistoryDisplay = ({
|
|||||||
<Flex gap='middle' align='center' justify='flex-end'>
|
<Flex gap='middle' align='center' justify='flex-end'>
|
||||||
{!startDate && !endDate && (
|
{!startDate && !endDate && (
|
||||||
<>
|
<>
|
||||||
{loading == true && chartRows.length != 0 && <LoadingOutlined />}
|
{loading == true && chartRows.length != 0 && (
|
||||||
|
<LoadingOutlined />
|
||||||
|
)}
|
||||||
<Segmented
|
<Segmented
|
||||||
size='small'
|
size='small'
|
||||||
options={[
|
options={[
|
||||||
@ -456,6 +461,7 @@ const ModelHistoryDisplay = ({
|
|||||||
style={{
|
style={{
|
||||||
height: toCssHeight(height),
|
height: toCssHeight(height),
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
|
gap: 12,
|
||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
minHeight: 0
|
minHeight: 0
|
||||||
}}
|
}}
|
||||||
@ -465,8 +471,7 @@ const ModelHistoryDisplay = ({
|
|||||||
style={{
|
style={{
|
||||||
flexShrink: 0,
|
flexShrink: 0,
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
justifyContent: 'center',
|
justifyContent: 'center'
|
||||||
paddingBottom: 4
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<HistoryChartLegend
|
<HistoryChartLegend
|
||||||
@ -475,7 +480,7 @@ const ModelHistoryDisplay = ({
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div style={{ flex: 1, minHeight: 0 }}>
|
<div style={{ flex: 1, minHeight: 0, overflow: 'hidden' }}>
|
||||||
{chartRows.length > 0 && (
|
{chartRows.length > 0 && (
|
||||||
<HistoryEChart
|
<HistoryEChart
|
||||||
chartRows={chartRows}
|
chartRows={chartRows}
|
||||||
@ -485,12 +490,20 @@ const ModelHistoryDisplay = ({
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{loading == true && chartRows.length == 0 && (
|
{loading == true && chartRows.length == 0 && (
|
||||||
<Flex justify='center' align='center' style={{ height: '100%' }}>
|
<Flex
|
||||||
|
justify='center'
|
||||||
|
align='center'
|
||||||
|
style={{ height: '100%', marginBottom: 6 }}
|
||||||
|
>
|
||||||
<LoadingOutlined />
|
<LoadingOutlined />
|
||||||
</Flex>
|
</Flex>
|
||||||
)}
|
)}
|
||||||
{loading == false && chartRows.length == 0 && (
|
{loading == false && chartRows.length == 0 && (
|
||||||
<Flex justify='center' align='center' style={{ height: '100%' }}>
|
<Flex
|
||||||
|
justify='center'
|
||||||
|
align='center'
|
||||||
|
style={{ height: '100%', marginBottom: 6 }}
|
||||||
|
>
|
||||||
<MissingPlaceholder message='No data available.' />
|
<MissingPlaceholder message='No data available.' />
|
||||||
</Flex>
|
</Flex>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user