+{: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
+ }
+}