From 05b43c0f21c87b746fc0ca155d36cc3460440a5b Mon Sep 17 00:00:00 2001 From: Christoph Kluge Date: Fri, 11 Aug 2023 13:34:30 +0200 Subject: [PATCH] Cleanup and fixes on new plots --- web/frontend/src/Analysis.root.svelte | 11 +- web/frontend/src/Status.root.svelte | 6 +- web/frontend/src/User.root.svelte | 6 +- web/frontend/src/plots/Histogram.svelte | 361 +++++++++---------- web/frontend/src/plots/Histogramuplot.svelte | 216 ----------- web/frontend/src/plots/Pie.svelte | 2 + web/frontend/src/utils.js | 43 +++ 7 files changed, 231 insertions(+), 414 deletions(-) delete mode 100644 web/frontend/src/plots/Histogramuplot.svelte diff --git a/web/frontend/src/Analysis.root.svelte b/web/frontend/src/Analysis.root.svelte index e7fe720..63751b4 100644 --- a/web/frontend/src/Analysis.root.svelte +++ b/web/frontend/src/Analysis.root.svelte @@ -5,9 +5,9 @@ import { Row, Col, Spinner, Card, Table, Icon } from 'sveltestrap' import Filters from './filters/Filters.svelte' import PlotSelection from './PlotSelection.svelte' - import Histogramuplot from './plots/Histogramuplot.svelte' + import Histogram from './plots/Histogram.svelte' import Pie, { colors } from './plots/Pie.svelte' - import { binsFromFootprint } from './plots/Histogram.svelte' + import { binsFromFootprint } from './utils.js' import ScatterPlot from './plots/Scatter.svelte' import PlotTable from './PlotTable.svelte' import Roofline from './plots/Roofline.svelte' @@ -204,7 +204,7 @@
{#key $statsQuery.data.stats[0].histDuration} -
{#key $statsQuery.data.stats[0].histNumNodes} - f.metric == metric).data, numBins) }))} itemsPerRow={ccconfig.plot_view_plotsPerRow}> - ({ m1, f1: $footprintsQuery.data.footprints.metrics.find(f => f.metric == m1).data, m2, f2: $footprintsQuery.data.footprints.metrics.find(f => f.metric == m2).data }))} diff --git a/web/frontend/src/Status.root.svelte b/web/frontend/src/Status.root.svelte index d402c08..244862c 100644 --- a/web/frontend/src/Status.root.svelte +++ b/web/frontend/src/Status.root.svelte @@ -2,7 +2,7 @@ import Refresher from './joblist/Refresher.svelte' import Roofline, { transformPerNodeData } from './plots/Roofline.svelte' import Pie, { colors } from './plots/Pie.svelte' - import Histogramuplot from './plots/Histogramuplot.svelte' + import Histogram from './plots/Histogram.svelte' import { Row, Col, Spinner, Card, CardHeader, CardTitle, CardBody, Table, Progress, Icon } from 'sveltestrap' import { init, convert2uplot } from './utils.js' import { scaleNumbers } from './units.js' @@ -213,7 +213,7 @@
{#key $mainQuery.data.stats} - {#key $mainQuery.data.stats} -
{#key $stats.data.jobsStatistics[0].histDuration} -
{#key $stats.data.jobsStatistics[0].histNumNodes} - String - - data: [{ value: Number, count: Number }] + - Todo --> -
(infoText = '')}> - {infoText} - -
- - +{#if data.length > 0} +
+{:else} + Cannot render histogram: No data! +{/if} - diff --git a/web/frontend/src/plots/Histogramuplot.svelte b/web/frontend/src/plots/Histogramuplot.svelte deleted file mode 100644 index d3e1aaa..0000000 --- a/web/frontend/src/plots/Histogramuplot.svelte +++ /dev/null @@ -1,216 +0,0 @@ - - - - -{#if data.length > 0} -
-{:else} - Cannot render histogram: No data! -{/if} - - diff --git a/web/frontend/src/plots/Pie.svelte b/web/frontend/src/plots/Pie.svelte index 0db451f..6355f09 100644 --- a/web/frontend/src/plots/Pie.svelte +++ b/web/frontend/src/plots/Pie.svelte @@ -23,6 +23,7 @@ Title, Tooltip, Legend, + Filler, ArcElement, CategoryScale } from 'chart.js'; @@ -31,6 +32,7 @@ Title, Tooltip, Legend, + Filler, ArcElement, CategoryScale ); diff --git a/web/frontend/src/utils.js b/web/frontend/src/utils.js index 37b9426..f68fec4 100644 --- a/web/frontend/src/utils.js +++ b/web/frontend/src/utils.js @@ -6,6 +6,7 @@ import { } from "@urql/svelte"; import { setContext, getContext, hasContext, onDestroy, tick } from "svelte"; import { readable } from "svelte/store"; +import { formatNumber } from './units.js' /* * Call this function only at component initialization time! @@ -323,3 +324,45 @@ export function convert2uplot(canvasData) { }) return uplotData } + +export function binsFromFootprint(weights, values, numBins) { + let min = 0, max = 0 + if (values.length != 0) { + for (let x of values) { + min = Math.min(min, x) + max = Math.max(max, x) + } + max += 1 // So that we have an exclusive range. + } + + if (numBins == null || numBins < 3) + numBins = 3 + + const bins = new Array(numBins).fill(0) + for (let i = 0; i < values.length; i++) + bins[Math.floor(((values[i] - min) / (max - min)) * numBins)] += weights ? weights[i] : 1 + + // return { + // label: idx => { + // let start = min + (idx / numBins) * (max - min) + // let stop = min + ((idx + 1) / numBins) * (max - min) + // return `${formatNumber(start)} - ${formatNumber(stop)}` + // }, + // bins: bins.map((count, idx) => ({ value: idx, count: count })), + // min: min, + // max: max + // } + + return { + bins: bins.map((count, idx) => ({ + value: idx => { // Get rounded down next integer to bins' Start-Stop Mean Value + let start = min + (idx / numBins) * (max - min) + let stop = min + ((idx + 1) / numBins) * (max - min) + return `${formatNumber(Math.floor((start+stop)/2))}` + }, + count: count + })), + min: min, + max: max + } +}