diff --git a/web/frontend/src/generic/JobCompare.svelte b/web/frontend/src/generic/JobCompare.svelte index 17da18f..345bfa8 100644 --- a/web/frontend/src/generic/JobCompare.svelte +++ b/web/frontend/src/generic/JobCompare.svelte @@ -19,12 +19,13 @@ queryStore, gql, getContextClient, - mutationStore, + // mutationStore, } from "@urql/svelte"; import { Row, Col, Card, Spinner } from "@sveltestrap/sveltestrap"; + import Comparogram from "./plots/Comparogram.svelte"; const ccconfig = getContext("cc-config"), - initialized = getContext("initialized"), + // initialized = getContext("initialized"), globalMetrics = getContext("globalMetrics"); const equalsCheck = (a, b) => { @@ -36,6 +37,8 @@ export let metrics = ccconfig.plot_list_selectedMetrics; let filter = [...filterBuffer]; + let comparePlotData = {}; + let jobIds = []; const sorting = { field: "startTime", type: "col", order: "DESC" }; /* GQL */ @@ -58,6 +61,8 @@ } `; + /* REACTIVES */ + $: compareData = queryStore({ client: client, query: compareQuery, @@ -65,6 +70,11 @@ }); $: matchedCompareJobs = $compareData.data != null ? $compareData.data.jobsMetricStats.length : -1; + $: if ($compareData.data != null) { + jobIds = []; + comparePlotData = {} + jobs2uplot($compareData.data.jobsMetricStats, metrics) + } /* FUNCTIONS */ // Force refresh list with existing unchanged variables (== usually would not trigger reactivity) @@ -96,6 +106,32 @@ } } + function jobs2uplot(jobs, metrics) { + // Prep + for (let m of metrics) { + // Get Unit + const rawUnit = globalMetrics.find((gm) => gm.name == m)?.unit + const metricUnit = (rawUnit?.prefix ? rawUnit.prefix : "") + (rawUnit?.base ? rawUnit.base : "") + // Init + comparePlotData[m] = {unit: metricUnit, data: [[],[],[],[]]} // data: [X, Y1, Y2, Y3] + } + + // Iterate jobs if exists + if (jobs) { + let plotIndex = 0 + jobs.forEach((j) => { + jobIds.push(j.jobId) + for (let s of j.stats) { + comparePlotData[s.name].data[0].push(plotIndex) + comparePlotData[s.name].data[1].push(s.data.min) + comparePlotData[s.name].data[2].push(s.data.avg) + comparePlotData[s.name].data[3].push(s.data.max) + } + plotIndex++ + }) + } +} + // Adapt for Persisting Job Selections in DB later down the line // const updateConfigurationMutation = ({ name, value }) => { // return mutationStore({ @@ -140,6 +176,18 @@ {:else} + {#each metrics as m} + + {/each} +

{#each $compareData.data.jobsMetricStats as job (job.jobId)} {job.jobId} diff --git a/web/frontend/src/generic/plots/Comparogram.svelte b/web/frontend/src/generic/plots/Comparogram.svelte new file mode 100644 index 0000000..92db086 --- /dev/null +++ b/web/frontend/src/generic/plots/Comparogram.svelte @@ -0,0 +1,281 @@ + + + + + +{#if data && data[0].length > 0} +
+{:else} + Cannot render plot: No series data returned for {metric} +{/if}