Invert time x-axis for node view metric plots

This commit is contained in:
Christoph Kluge 2023-08-01 18:37:50 +02:00
parent 36abed2093
commit 284a7079d6
3 changed files with 9 additions and 6 deletions

View File

@ -211,6 +211,7 @@
subCluster={$nodeMetricsData.data.nodeMetrics[0] subCluster={$nodeMetricsData.data.nodeMetrics[0]
.subCluster} .subCluster}
series={item.metric.series} series={item.metric.series}
forNode={true}
/> />
{:else if item.disabled === true && item.metric} {:else if item.disabled === true && item.metric}
<Card <Card

View File

@ -144,7 +144,8 @@
series={item.data.metric.series} series={item.data.metric.series}
metric={item.data.name} metric={item.data.name}
cluster={clusters.find(c => c.name == cluster)} cluster={clusters.find(c => c.name == cluster)}
subCluster={item.subCluster} /> subCluster={item.subCluster}
forNode={true} />
{:else if item.disabled === true && item.data} {:else if item.disabled === true && item.data}
<Card style="margin-left: 2rem;margin-right: 2rem;" body color="info">Metric disabled for subcluster <code>{selectedMetric}:{item.subCluster}</code></Card> <Card style="margin-left: 2rem;margin-right: 2rem;" body color="info">Metric disabled for subcluster <code>{selectedMetric}:{item.subCluster}</code></Card>
{:else} {:else}

View File

@ -37,6 +37,7 @@
export let useStatsSeries = null export let useStatsSeries = null
export let scope = 'node' export let scope = 'node'
export let isShared = false export let isShared = false
export let forNode = false
if (useStatsSeries == null) if (useStatsSeries == null)
useStatsSeries = statisticsSeries != null useStatsSeries = statisticsSeries != null
@ -130,7 +131,7 @@
scale: 'x', scale: 'x',
space: 35, space: 35,
incrs: timeIncrs(timestep, maxX), incrs: timeIncrs(timestep, maxX),
values: (_, vals) => vals.map(v => formatTime(v)) values: (_, vals) => forNode ? vals.reverse().map(v => formatTime(v, forNode)) : vals.map(v => formatTime(v))
}, },
{ {
scale: 'y', scale: 'y',
@ -250,15 +251,15 @@
</script> </script>
<script context="module"> <script context="module">
export function formatTime(t) { export function formatTime(t, forNode = false) {
let h = Math.floor(t / 3600) let h = Math.floor(t / 3600)
let m = Math.floor((t % 3600) / 60) let m = Math.floor((t % 3600) / 60)
if (h == 0) if (h == 0)
return `${m}m` return forNode ? `-${m}m` : `${m}m`
else if (m == 0) else if (m == 0)
return `${h}h` return forNode ? `-${h}h` : `${h}h`
else else
return `${h}:${m}h` return forNode ? `-${h}:${m}h` : `${h}:${m}h`
} }
export function timeIncrs(timestep, maxX) { export function timeIncrs(timestep, maxX) {