Skip to content

Commit 8483304

Browse files
committed
feat: update dashboard charts to show 4 charts per row
and some small adjustments around it (x axis labels, padding) to make this fit
1 parent d7126c5 commit 8483304

File tree

4 files changed

+31
-8
lines changed

4 files changed

+31
-8
lines changed

plugins/plugin-codeflare/src/components/Chart.tsx

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export default class BaseChart extends React.PureComponent<Props> {
6969
private static tickLabelFontSize = BaseChart.fontSize - 1
7070

7171
private static readonly dimensions = {
72-
width: 150,
72+
width: 120,
7373
height: 200,
7474
}
7575

@@ -155,7 +155,8 @@ export default class BaseChart extends React.PureComponent<Props> {
155155
celsius: (value: number) => ~~value + "C",
156156
percentage: (value: number) => value + "%",
157157
memory: (value: number) => ~~(value / 1024 / 1024) + " GiB",
158-
timestamp: (timestamp: number) => (timestamp / 1000 / 60).toFixed(1) + "m",
158+
timestamp: (timestamp: number) =>
159+
timestamp < 60000 ? (timestamp / 1000).toFixed(0) + "s" : (timestamp / 1000 / 60).toFixed(1) + "m",
159160
}
160161

161162
private readonly minDomain = {
@@ -172,8 +173,28 @@ export default class BaseChart extends React.PureComponent<Props> {
172173
}
173174

174175
private xAxis() {
176+
// TODO, factor this out into a State variable?
177+
const { min, max } = this.props.charts.reduce(
178+
(M, chart) =>
179+
chart.series.reduce(
180+
(M, series) =>
181+
series.data.reduce((M, point) => {
182+
M.min = Math.min(M.min, point.x)
183+
M.max = Math.max(M.max, point.x)
184+
return M
185+
}, M),
186+
M
187+
),
188+
{ min: Number.MAX_VALUE, max: Number.MIN_VALUE }
189+
)
190+
175191
return (
176-
<ChartAxis scale="time" style={BaseChart.axisStyle} tickFormat={BaseChart.formatters.timestamp} tickCount={3} />
192+
<ChartAxis
193+
scale="time"
194+
style={BaseChart.axisStyle}
195+
tickFormat={BaseChart.formatters.timestamp}
196+
tickValues={[(max - min) / 4, max]}
197+
/>
177198
)
178199
}
179200

plugins/plugin-codeflare/src/components/GPUChart.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export default class GPUChart extends React.PureComponent<Props, State> {
9090
padding: GPUChart.padding,
9191
yAxes: [
9292
{
93-
label: "GPU Utilization",
93+
label: "Utilization",
9494
format: "percentage",
9595
y: data[0].y,
9696
tickFormat: data[0].tickFormat,

plugins/plugin-codeflare/src/components/VmstatChart.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export default class VmstatChart extends React.PureComponent<Props, State> {
7676
padding: VmstatChart.padding,
7777
yAxes: [
7878
{
79-
label: "CPU Utilization",
79+
label: "Utilization",
8080
format: "percentage",
8181
y: data[0].y,
8282
tickFormat: data[0].tickFormat,

plugins/plugin-codeflare/web/scss/components/Dashboard/Charts.scss

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,18 @@
1818

1919
@include ChartGrid {
2020
display: grid;
21-
grid-gap: 1em;
22-
padding: 2em;
23-
grid-template-columns: 1fr 1fr 1fr;
21+
grid-gap: 0.6875em;
22+
padding: 2em 1em;
23+
grid-template-columns: repeat(4, 1fr);
2424
grid-auto-rows: minmax(300px, max-content);
2525
}
2626

2727
@include ChartContainer {
2828
background-color: var(--color-base01);
2929

3030
&.pf-c-tile {
31+
padding-left: 1em;
32+
padding-right: 1em;
3133
--pf-c-tile__title--Color: var(--color-text-01);
3234
--pf-c-tile--before--BorderColor: var(--color-table-border3);
3335
}

0 commit comments

Comments
 (0)