Improve binned data histogram legends

This commit is contained in:
Christoph Kluge 2023-12-13 11:58:14 +01:00
parent 07073e290a
commit b829a5aafe
5 changed files with 18 additions and 12 deletions

View File

@ -389,9 +389,10 @@
<Histogram <Histogram
data={convert2uplot(item.bins)} data={convert2uplot(item.bins)}
width={width} height={250} width={width} height={250}
usesBins={true}
title="Average Distribution of '{item.metric}'" title="Average Distribution of '{item.metric}'"
xlabel={`${item.metric} bin maximum [${(metricConfig(cluster.name, item.metric)?.unit?.prefix ? metricConfig(cluster.name, item.metric)?.unit?.prefix : '') + xlabel={`${item.metric} bin maximum ${(metricConfig(cluster.name, item.metric)?.unit?.prefix ? '[' + metricConfig(cluster.name, item.metric)?.unit?.prefix : '') +
(metricConfig(cluster.name, item.metric)?.unit?.base ? metricConfig(cluster.name, item.metric)?.unit?.base : '')}]`} (metricConfig(cluster.name, item.metric)?.unit?.base ? metricConfig(cluster.name, item.metric)?.unit?.base + ']' : '')}`}
xunit={`${(metricConfig(cluster.name, item.metric)?.unit?.prefix ? metricConfig(cluster.name, item.metric)?.unit?.prefix : '') + xunit={`${(metricConfig(cluster.name, item.metric)?.unit?.prefix ? metricConfig(cluster.name, item.metric)?.unit?.prefix : '') +
(metricConfig(cluster.name, item.metric)?.unit?.base ? metricConfig(cluster.name, item.metric)?.unit?.base : '')}`} (metricConfig(cluster.name, item.metric)?.unit?.base ? metricConfig(cluster.name, item.metric)?.unit?.base : '')}`}
ylabel="Normalized Hours" ylabel="Normalized Hours"

View File

@ -705,9 +705,10 @@
<Histogram <Histogram
data={convert2uplot(item.data)} data={convert2uplot(item.data)}
usesBins={true}
width={width} height={250} width={width} height={250}
title="Distribution of '{item.metric}'" title="Distribution of '{item.metric}' averages"
xlabel={`${item.metric} bin maximum [${item.unit}]`} xlabel={`${item.metric} bin maximum ${item?.unit ? `[${item.unit}]` : ``}`}
xunit={item.unit} xunit={item.unit}
ylabel="Number of Jobs" ylabel="Number of Jobs"
yunit="Jobs"/> yunit="Jobs"/>

View File

@ -192,9 +192,10 @@
<Histogram <Histogram
data={convert2uplot(item.data)} data={convert2uplot(item.data)}
usesBins={true}
width={width} height={250} width={width} height={250}
title="Distribution of '{item.metric}'" title="Distribution of '{item.metric}' averages"
xlabel={`${item.metric} bin maximum [${item.unit}]`} xlabel={`${item.metric} bin maximum ${item?.unit ? `[${item.unit}]` : ``}`}
xunit={item.unit} xunit={item.unit}
ylabel="Number of Jobs" ylabel="Number of Jobs"
yunit="Jobs"/> yunit="Jobs"/>

View File

@ -11,6 +11,7 @@
import { Card } from 'sveltestrap' import { Card } from 'sveltestrap'
export let data export let data
export let usesBins = false
export let width = 500 export let width = 500
export let height = 300 export let height = 300
export let title = '' export let title = ''
@ -160,6 +161,14 @@
series: [ series: [
{ {
label: xunit !== '' ? xunit : null, label: xunit !== '' ? xunit : null,
value: (u, ts, sidx, didx) => {
if (usesBins) {
const min = u.data[sidx][didx - 1] ? u.data[sidx][didx - 1] : 0
const max = u.data[sidx][didx]
ts = min + '-' + max // narrow spaces
}
return ts
}
}, },
Object.assign({ Object.assign({
label: yunit !== '' ? yunit : null, label: yunit !== '' ? yunit : null,

View File

@ -318,12 +318,6 @@ export function checkMetricDisabled(m, c, s) { //[m]etric, [c]luster, [s]ubclust
export function convert2uplot(canvasData) { export function convert2uplot(canvasData) {
// Prep: Uplot Data Structure // Prep: Uplot Data Structure
let uplotData = [[],[]] // [X, Y1, Y2, ...] let uplotData = [[],[]] // [X, Y1, Y2, ...]
// MetricHisto Only: Check if 1st bin not-null -> Set 0-Value bin for scaling
// Else: Only Single 0-Value bin returned -> No reset required
if (canvasData[0]?.bin) {
uplotData[0].push(0)
uplotData[1].push(0)
}
// Iterate // Iterate
canvasData.forEach( cd => { canvasData.forEach( cd => {
if (Object.keys(cd).length == 4) { // MetricHisto Datafromat if (Object.keys(cd).length == 4) { // MetricHisto Datafromat