diff --git a/web/frontend/src/Node.root.svelte b/web/frontend/src/Node.root.svelte index 3fde017..c78139a 100644 --- a/web/frontend/src/Node.root.svelte +++ b/web/frontend/src/Node.root.svelte @@ -208,7 +208,6 @@ {#if item.disabled === false && item.metric} c.name == cluster)} diff --git a/web/frontend/src/Systems.root.svelte b/web/frontend/src/Systems.root.svelte index 8a5fee2..488cdad 100644 --- a/web/frontend/src/Systems.root.svelte +++ b/web/frontend/src/Systems.root.svelte @@ -50,7 +50,6 @@ const clusters = getContext("clusters"); const globalMetrics = getContext("globalMetrics"); - let plotHeight = 300; let hostnameFilter = ""; let selectedMetric = ccconfig.system_view_selectedMetric; @@ -208,7 +207,6 @@ {#if item.disabled === false && item.data} { handleZoom(detail, metric.data.name) }} - width={plotWidth} height={plotHeight} timestep={metric.data.metric.timestep} scope={metric.data.scope} diff --git a/web/frontend/src/generic/plots/MetricPlot.svelte b/web/frontend/src/generic/plots/MetricPlot.svelte index fc7d8d5..ba7533f 100644 --- a/web/frontend/src/generic/plots/MetricPlot.svelte +++ b/web/frontend/src/generic/plots/MetricPlot.svelte @@ -6,8 +6,7 @@ Properties: - `metric String`: The metric name - `scope String?`: Scope of the displayed data [Default: node] - - `width Number`: The plot width - - `height Number`: The plot height + - `height Number?`: The plot height [Default: 300] - `timestep Number`: The timestep used for X-axis rendering - `series [GraphQL.Series]`: The metric data object - `useStatsSeries Bool?`: If this plot uses the statistics Min/Max/Median representation; automatically set to according bool [Default: null] @@ -118,8 +117,7 @@ export let metric; export let scope = "node"; - export let width; - export let height; + export let height = 300; export let timestep; export let series; export let useStatsSeries = null; @@ -132,15 +130,17 @@ export let numaccs = 0; export let zoomState = null; + let width; + if (useStatsSeries == null) useStatsSeries = statisticsSeries != null; if (useStatsSeries == false && series == null) useStatsSeries = true; - const usesMeanStatsSeries = (useStatsSeries && statisticsSeries.mean.length != 0) + const usesMeanStatsSeries = (useStatsSeries && statisticsSeries.mean.length != 0) const dispatch = createEventDispatcher(); const subClusterTopology = getContext("getHardwareTopology")(cluster, subCluster); const metricConfig = getContext("getMetricConfig")(cluster, subCluster, metric); const clusterCockpitConfig = getContext("cc-config"); - const renderSleepTime = 100; + const renderSleepTime = 200; const normalLineColor = "#000000"; const lineWidth = clusterCockpitConfig.plot_general_lineWidth / window.devicePixelRatio; @@ -164,8 +164,6 @@ let resampleResolutions; let resampleMinimum; - let wrapperWidth = 0; - if (resampleConfig) { resampleTrigger = Number(resampleConfig.trigger) resampleResolutions = [...resampleConfig.resolutions]; @@ -498,23 +496,32 @@ // RENDER HANDLING let plotWrapper = null; let uplot = null; - // let timeoutId = null; + let timeoutId = null; - function render(func_width, func_height) { + function render(ren_width, ren_height) { if (!uplot) { // Init uPlot - opts.width = func_width; - opts.height = func_height; + opts.width = ren_width; + opts.height = ren_height; if (zoomState) { opts.scales = {...zoomState} } // console.log('Init Sizes ...', { width: opts.width, height: opts.height }) uplot = new uPlot(opts, plotData, plotWrapper); } else { // Update size - // console.log('Update uPlot ...', { width: func_width, height: func_height }) - uplot.setSize({ width: func_width, height: func_height }); + // console.log('Update uPlot ...', { width: ren_width, height: ren_height }) + uplot.setSize({ width: ren_width, height: ren_height }); } } + function onSizeChange(chg_width, chg_height) { + if (!uplot) return; + if (timeoutId != null) clearTimeout(timeoutId); + timeoutId = setTimeout(() => { + timeoutId = null; + render(chg_width, chg_height); + }, renderSleepTime); + } + onMount(() => { // Setup Wrapper if (series[0].data.length > 0) { @@ -525,35 +532,31 @@ plotWrapper.style.backgroundColor = backgroundColor(); plotWrapper.style.borderRadius = "5px"; } + // Init Plot + render(width, height); }); onDestroy(() => { - // if (timeoutId != null) clearTimeout(timeoutId); + if (timeoutId != null) clearTimeout(timeoutId); if (uplot) uplot.destroy(); }); - $: width = wrapperWidth; - - // This renders uPlot initially and updates it on all size changes - $: if (width > 0 && height > 0) { - // console.log('Triggered render() ...') - - // if (timeoutId != null) { - // clearTimeout(timeoutId); - // timeoutId = null; - // } - // timeoutId = setTimeout(render(width, height), renderSleepTime); - - setTimeout(render(width, height), renderSleepTime); + // This updates it on all size changes + // Condition for reactive triggering (eg scope change) + $: if (series[0].data.length > 0) { + onSizeChange(width, height); } + - -{#if series[0].data.length > 0} -
-{:else} - Cannot render plot: No series data returned for {metric} -{/if} + +
+ {#if series[0].data.length > 0} +
+ {:else} + Cannot render plot: No series data returned for {metric} + {/if} +
diff --git a/web/frontend/src/job/Metric.svelte b/web/frontend/src/job/Metric.svelte index ab1616a..0ff8125 100644 --- a/web/frontend/src/job/Metric.svelte +++ b/web/frontend/src/job/Metric.svelte @@ -7,7 +7,6 @@ - `metricUnit Object`: The metrics GQL unit object - `nativeScope String`: The metrics native scope - `scopes [String]`: The scopes returned for this metric - - `width Number`: Nested plot width - `rawData [Object]`: Metric data for all scopes returned for this metric - `isShared Bool?`: If this job used shared resources; will adapt threshold indicators accordingly in downstream plots [Default: false] --> @@ -38,7 +37,6 @@ export let metricUnit; export let nativeScope; export let scopes; - export let width; export let rawData; export let isShared = false; @@ -165,7 +163,6 @@ } $: data = rawData[selectedScopeIndex]; - $: series = data?.series?.filter( (series) => selectedHost == null || series.hostname == selectedHost, ); @@ -203,8 +200,6 @@ {:else if series != null && !patternMatches} { handleZoom(detail) }} - {width} - height={300} cluster={job.cluster} subCluster={job.subCluster} timestep={data.timestep} @@ -217,8 +212,6 @@ {:else if statsSeries[selectedScopeIndex] != null && patternMatches} { handleZoom(detail) }} - {width} - height={300} cluster={job.cluster} subCluster={job.subCluster} timestep={data.timestep}