Skip to content

Commit 469d0d1

Browse files
authored
Merge pull request #29 from headlamp-k8s/chartsAlignmentFix
prometheus: Fix charts CSS
2 parents d30264a + 7926708 commit 469d0d1

File tree

1 file changed

+39
-38
lines changed

1 file changed

+39
-38
lines changed

prometheus/src/common.tsx

Lines changed: 39 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,10 @@ export function GenericMetricsChart(props: {
8888
display="flex"
8989
justifyContent="space-around"
9090
alignItems="center"
91-
style={{ marginBottom: '1rem', maxWidth: '900px' }}
91+
style={{ marginBottom: '1rem', margin: '0 auto', width: '0' }}
9292
>
9393
{state === prometheusState.INSTALLED
9494
? [
95-
<Box></Box>, // This Box is just for leveling the buttons alignment
9695
<ToggleButtonGroup
9796
onChange={handleChartVariantChange}
9897
size="small"
@@ -120,39 +119,37 @@ export function GenericMetricsChart(props: {
120119
</Box>
121120

122121
{prometheusInfo ? (
123-
<Box style={{ justifyContent: 'center', display: 'flex' }}>
124-
<Box container spacing={2} style={{ height: '40vh', width: '80%' }}>
125-
{chartVariant === 'cpu' && (
126-
<CPUChart
127-
query={props.cpuQuery}
128-
autoRefresh={refresh}
129-
prometheusPrefix={`${prometheusInfo.podNamespace}/pods/${prometheusInfo.podName}`}
130-
/>
131-
)}
132-
{chartVariant === 'memory' && (
133-
<MemoryChart
134-
query={props.memoryQuery}
135-
autoRefresh={refresh}
136-
prometheusPrefix={`${prometheusInfo.podNamespace}/pods/${prometheusInfo.podName}`}
137-
/>
138-
)}
139-
{chartVariant === 'network' && (
140-
<NetworkChart
141-
rxQuery={props.networkRxQuery}
142-
txQuery={props.networkTxQuery}
143-
autoRefresh={refresh}
144-
prometheusPrefix={`${prometheusInfo.podNamespace}/pods/${prometheusInfo.podName}`}
145-
/>
146-
)}
147-
{chartVariant === 'filesystem' && (
148-
<FilesystemChart
149-
readQuery={props.filesystemReadQuery}
150-
writeQuery={props.filesystemWriteQuery}
151-
autoRefresh={refresh}
152-
prometheusPrefix={`${prometheusInfo.podNamespace}/pods/${prometheusInfo.podName}`}
153-
/>
154-
)}
155-
</Box>
122+
<Box style={{ justifyContent: 'center', display: 'flex', height: '40vh', width: '80%', margin: '0 auto' }}>
123+
{chartVariant === 'cpu' && (
124+
<CPUChart
125+
query={props.cpuQuery}
126+
autoRefresh={refresh}
127+
prometheusPrefix={`${prometheusInfo.podNamespace}/pods/${prometheusInfo.podName}`}
128+
/>
129+
)}
130+
{chartVariant === 'memory' && (
131+
<MemoryChart
132+
query={props.memoryQuery}
133+
autoRefresh={refresh}
134+
prometheusPrefix={`${prometheusInfo.podNamespace}/pods/${prometheusInfo.podName}`}
135+
/>
136+
)}
137+
{chartVariant === 'network' && (
138+
<NetworkChart
139+
rxQuery={props.networkRxQuery}
140+
txQuery={props.networkTxQuery}
141+
autoRefresh={refresh}
142+
prometheusPrefix={`${prometheusInfo.podNamespace}/pods/${prometheusInfo.podName}`}
143+
/>
144+
)}
145+
{chartVariant === 'filesystem' && (
146+
<FilesystemChart
147+
readQuery={props.filesystemReadQuery}
148+
writeQuery={props.filesystemWriteQuery}
149+
autoRefresh={refresh}
150+
prometheusPrefix={`${prometheusInfo.podNamespace}/pods/${prometheusInfo.podName}`}
151+
/>
152+
)}
156153
</Box>
157154
) : state === prometheusState.LOADING ? (
158155
<Box m={2}>
@@ -298,6 +295,7 @@ export function CPUChart(props: { query: string; prometheusPrefix: string; autoR
298295

299296
const YTickProps = {
300297
domain: ['dataMin', 'auto'],
298+
width: 80,
301299
};
302300

303301
return (
@@ -352,11 +350,12 @@ export function MemoryChart(props: {
352350
domain: ['dataMin', 'auto'],
353351
tick: ({ x, y, payload }) => (
354352
<g transform={`translate(${x},${y})`} fill={theme.palette.chartStyles.labelColor}>
355-
<text x={-25} y={0} dy={0} textAnchor="middle">
353+
<text x={-35} y={0} dy={0} textAnchor="middle">
356354
{formatBytes(payload.value)}
357355
</text>
358356
</g>
359357
),
358+
width: 80,
360359
};
361360

362361
return (
@@ -429,11 +428,12 @@ export function NetworkChart(props: {
429428
domain: ['dataMin', 'auto'],
430429
tick: ({ x, y, payload }) => (
431430
<g transform={`translate(${x},${y})`} fill={theme.palette.chartStyles.labelColor}>
432-
<text x={-25} y={0} dy={0} textAnchor="middle">
431+
<text x={-35} y={0} dy={0} textAnchor="middle">
433432
{formatBytes(payload.value)}
434433
</text>
435434
</g>
436435
),
436+
width: 80,
437437
}}
438438
fetchMetrics={fetchMetrics}
439439
CustomTooltip={CustomTooltipFormatBytes}
@@ -492,11 +492,12 @@ export function FilesystemChart(props: {
492492
domain: ['dataMin', 'auto'],
493493
tick: ({ x, y, payload }) => (
494494
<g transform={`translate(${x},${y})`} fill={theme.palette.chartStyles.labelColor}>
495-
<text x={-25} y={0} dy={0} textAnchor="middle">
495+
<text x={-35} y={0} dy={0} textAnchor="middle">
496496
{formatBytes(payload.value)}
497497
</text>
498498
</g>
499499
),
500+
width: 80,
500501
}}
501502
fetchMetrics={fetchMetrics}
502503
CustomTooltip={CustomTooltipFormatBytes}

0 commit comments

Comments
 (0)