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}
series={item.metric.series}
forNode={true}
/>
{:else if item.disabled === true && item.metric}
<Card

View File

@ -144,7 +144,8 @@
series={item.data.metric.series}
metric={item.data.name}
cluster={clusters.find(c => c.name == cluster)}
subCluster={item.subCluster} />
subCluster={item.subCluster}
forNode={true} />
{: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>
{:else}

View File

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