mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2024-12-26 13:29:05 +01:00
fix: fix plot render for summed metrics on scope change
This commit is contained in:
parent
5da6baf828
commit
0b9f74f4f4
@ -64,6 +64,12 @@
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handle special *-stat scopes
|
||||||
|
if (scope.match(/(.*)-stat$/)) {
|
||||||
|
const statParts = scope.split('-');
|
||||||
|
scope = statParts[0]
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(scope == "node" && isShared == false) ||
|
(scope == "node" && isShared == false) ||
|
||||||
metricConfig?.aggregation == "avg"
|
metricConfig?.aggregation == "avg"
|
||||||
@ -130,6 +136,7 @@
|
|||||||
export let numhwthreads = 0;
|
export let numhwthreads = 0;
|
||||||
export let numaccs = 0;
|
export let numaccs = 0;
|
||||||
export let zoomState = null;
|
export let zoomState = null;
|
||||||
|
export let thresholdState = null;
|
||||||
|
|
||||||
if (useStatsSeries == null) useStatsSeries = statisticsSeries != null;
|
if (useStatsSeries == null) useStatsSeries = statisticsSeries != null;
|
||||||
if (useStatsSeries == false && series == null) useStatsSeries = true;
|
if (useStatsSeries == false && series == null) useStatsSeries = true;
|
||||||
@ -468,12 +475,14 @@
|
|||||||
// console.log('Dispatch Zoom with Res from / to', timestep, closest)
|
// console.log('Dispatch Zoom with Res from / to', timestep, closest)
|
||||||
dispatch('zoom', {
|
dispatch('zoom', {
|
||||||
newRes: closest,
|
newRes: closest,
|
||||||
lastZoomState: u?.scales
|
lastZoomState: u?.scales,
|
||||||
|
lastThreshold: thresholds?.normal
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dispatch('zoom', {
|
dispatch('zoom', {
|
||||||
lastZoomState: u?.scales
|
lastZoomState: u?.scales,
|
||||||
|
lastThreshold: thresholds?.normal
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -498,16 +507,19 @@
|
|||||||
let timeoutId = null;
|
let timeoutId = null;
|
||||||
|
|
||||||
function render(ren_width, ren_height) {
|
function render(ren_width, ren_height) {
|
||||||
if (!uplot) { // Init uPlot
|
if (!uplot) {
|
||||||
opts.width = ren_width;
|
opts.width = ren_width;
|
||||||
opts.height = ren_height;
|
opts.height = ren_height;
|
||||||
if (zoomState) {
|
if (zoomState && metricConfig?.aggregation == "avg") {
|
||||||
opts.scales = {...zoomState}
|
opts.scales = {...zoomState}
|
||||||
|
} else if (zoomState && metricConfig?.aggregation == "sum") {
|
||||||
|
// Allow Zoom In === Ymin changed
|
||||||
|
if (zoomState.y.min !== 0) { // scope change?: only use zoomState if thresholds match
|
||||||
|
if ((thresholdState === thresholds?.normal)) { opts.scales = {...zoomState} };
|
||||||
|
} // else: reset scaling to default
|
||||||
}
|
}
|
||||||
// console.log('Init Sizes ...', { width: opts.width, height: opts.height })
|
|
||||||
uplot = new uPlot(opts, plotData, plotWrapper);
|
uplot = new uPlot(opts, plotData, plotWrapper);
|
||||||
} else { // Update size
|
} else {
|
||||||
// console.log('Update uPlot ...', { width: ren_width, height: ren_height })
|
|
||||||
uplot.setSize({ width: ren_width, height: ren_height });
|
uplot.setSize({ width: ren_width, height: ren_height });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,7 @@
|
|||||||
let statsSeries = rawData.map((data) => data?.statisticsSeries ? data.statisticsSeries : null);
|
let statsSeries = rawData.map((data) => data?.statisticsSeries ? data.statisticsSeries : null);
|
||||||
let zoomState = null;
|
let zoomState = null;
|
||||||
let pendingZoomState = null;
|
let pendingZoomState = null;
|
||||||
|
let thresholdState = null;
|
||||||
|
|
||||||
const dispatch = createEventDispatcher();
|
const dispatch = createEventDispatcher();
|
||||||
const statsPattern = /(.*)-stat$/;
|
const statsPattern = /(.*)-stat$/;
|
||||||
@ -96,18 +97,24 @@
|
|||||||
(pendingZoomState?.x?.min !== detail?.lastZoomState?.x?.min) &&
|
(pendingZoomState?.x?.min !== detail?.lastZoomState?.x?.min) &&
|
||||||
(pendingZoomState?.y?.max !== detail?.lastZoomState?.y?.max)
|
(pendingZoomState?.y?.max !== detail?.lastZoomState?.y?.max)
|
||||||
) {
|
) {
|
||||||
pendingZoomState = {...detail.lastZoomState}
|
pendingZoomState = {...detail.lastZoomState};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (detail?.lastThreshold) { // Handle to correctly reset on summed metric scope change
|
||||||
|
thresholdState = detail.lastThreshold;
|
||||||
|
} else {
|
||||||
|
thresholdState = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (detail?.newRes) { // Triggers GQL
|
if (detail?.newRes) { // Triggers GQL
|
||||||
pendingResolution = detail.newRes
|
pendingResolution = detail.newRes;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let metricData;
|
let metricData;
|
||||||
let selectedScopes = [...scopes]
|
let selectedScopes = [...scopes];
|
||||||
const dbid = job.id;
|
const dbid = job.id;
|
||||||
const selectedMetrics = [metricName]
|
const selectedMetrics = [metricName];
|
||||||
|
|
||||||
$: if (selectedScope || pendingResolution) {
|
$: if (selectedScope || pendingResolution) {
|
||||||
|
|
||||||
@ -209,6 +216,7 @@
|
|||||||
{series}
|
{series}
|
||||||
{isShared}
|
{isShared}
|
||||||
{zoomState}
|
{zoomState}
|
||||||
|
{thresholdState}
|
||||||
/>
|
/>
|
||||||
{:else if statsSeries[selectedScopeIndex] != null && patternMatches}
|
{:else if statsSeries[selectedScopeIndex] != null && patternMatches}
|
||||||
<Timeseries
|
<Timeseries
|
||||||
@ -221,6 +229,7 @@
|
|||||||
{series}
|
{series}
|
||||||
{isShared}
|
{isShared}
|
||||||
{zoomState}
|
{zoomState}
|
||||||
|
{thresholdState}
|
||||||
statisticsSeries={statsSeries[selectedScopeIndex]}
|
statisticsSeries={statsSeries[selectedScopeIndex]}
|
||||||
useStatsSeries={!!statsSeries[selectedScopeIndex]}
|
useStatsSeries={!!statsSeries[selectedScopeIndex]}
|
||||||
/>
|
/>
|
||||||
|
Loading…
Reference in New Issue
Block a user