add plot cursor sync to nodelist rows

This commit is contained in:
Christoph Kluge
2025-11-12 16:44:49 +01:00
parent fb278182d3
commit f56783a439
3 changed files with 26 additions and 6 deletions

View File

@@ -39,7 +39,7 @@
yunit = "", yunit = "",
title = "", title = "",
forResources = false, forResources = false,
plotSync, plotSync = null,
} = $props(); } = $props();
/* Const Init */ /* Const Init */
@@ -204,11 +204,7 @@
live: true, live: true,
}, },
cursor: { cursor: {
drag: { x: true, y: true }, drag: { x: true, y: true }
sync: {
key: plotSync.key,
scales: ["x", null],
}
} }
}; };
@@ -293,6 +289,14 @@
if (!uplot) { if (!uplot) {
opts.width = ren_width; opts.width = ren_width;
opts.height = ren_height; opts.height = ren_height;
if (plotSync) {
opts.cursor.sync = {
key: plotSync.key,
scales: ["x", null],
}
}
uplot = new uPlot(opts, data, plotWrapper); // Data is uplot formatted [[X][Ymin][Yavg][Ymax]] uplot = new uPlot(opts, data, plotWrapper); // Data is uplot formatted [[X][Ymin][Yavg][Ymax]]
plotSync.sub(uplot) plotSync.sub(uplot)
} else { } else {

View File

@@ -48,6 +48,7 @@
zoomState = null, zoomState = null,
thresholdState = null, thresholdState = null,
extendedLegendData = null, extendedLegendData = null,
plotSync = null,
onZoom onZoom
} = $props(); } = $props();
@@ -576,6 +577,14 @@
if (!uplot) { if (!uplot) {
opts.width = ren_width; opts.width = ren_width;
opts.height = ren_height; opts.height = ren_height;
if (plotSync) {
opts.cursor.sync = {
key: plotSync.key,
scales: ["x", null],
}
}
if (zoomState && metricConfig?.aggregation == "avg") { if (zoomState && metricConfig?.aggregation == "avg") {
opts.scales = {...zoomState} opts.scales = {...zoomState}
} else if (zoomState && metricConfig?.aggregation == "sum") { } else if (zoomState && metricConfig?.aggregation == "sum") {
@@ -584,6 +593,7 @@
if ((thresholdState === thresholds?.normal)) { opts.scales = {...zoomState} }; if ((thresholdState === thresholds?.normal)) { opts.scales = {...zoomState} };
} // else: reset scaling to default } // else: reset scaling to default
} }
uplot = new uPlot(opts, plotData, plotWrapper); uplot = new uPlot(opts, plotData, plotWrapper);
} else { } else {
uplot.setSize({ width: ren_width, height: ren_height }); uplot.setSize({ width: ren_width, height: ren_height });

View File

@@ -13,6 +13,7 @@
gql, gql,
getContextClient, getContextClient,
} from "@urql/svelte"; } from "@urql/svelte";
import uPlot from "uplot";
import { Card, CardBody, Spinner } from "@sveltestrap/sveltestrap"; import { Card, CardBody, Spinner } from "@sveltestrap/sveltestrap";
import { maxScope, checkMetricDisabled, scramble, scrambleNames } from "../../generic/utils.js"; import { maxScope, checkMetricDisabled, scramble, scrambleNames } from "../../generic/utils.js";
import MetricPlot from "../../generic/plots/MetricPlot.svelte"; import MetricPlot from "../../generic/plots/MetricPlot.svelte";
@@ -25,6 +26,9 @@
selectedMetrics, selectedMetrics,
} = $props(); } = $props();
/* Var Init*/
let plotSync = uPlot.sync(`nodeMetricStack-${nodeData.host}`);
/* Const Init */ /* Const Init */
const client = getContextClient(); const client = getContextClient();
const paging = { itemsPerPage: 50, page: 1 }; const paging = { itemsPerPage: 50, page: 1 };
@@ -159,6 +163,7 @@
statisticsSeries={metricData.data?.metric.statisticsSeries} statisticsSeries={metricData.data?.metric.statisticsSeries}
useStatsSeries={!!metricData.data?.metric.statisticsSeries} useStatsSeries={!!metricData.data?.metric.statisticsSeries}
height={175} height={175}
{plotSync}
forNode forNode
/> />
<div class="my-2"></div> <div class="my-2"></div>
@@ -172,6 +177,7 @@
series={metricData.data.metric.series} series={metricData.data.metric.series}
height={175} height={175}
{extendedLegendData} {extendedLegendData}
{plotSync}
forNode forNode
/> />
{/key} {/key}