From 3ebe45aa6549525c9fbdf343808e532e8b557fa0 Mon Sep 17 00:00:00 2001 From: Luc Mcgrady Date: Sun, 13 Jul 2025 16:47:33 +0100 Subject: [PATCH] Fix: Simulator/workload transition --- ts/routes/deck-options/SimulatorModal.svelte | 33 +++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/ts/routes/deck-options/SimulatorModal.svelte b/ts/routes/deck-options/SimulatorModal.svelte index de065fb30..84da9213b 100644 --- a/ts/routes/deck-options/SimulatorModal.svelte +++ b/ts/routes/deck-options/SimulatorModal.svelte @@ -161,6 +161,13 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html } finally { simulating = false; if (resp) { + // Clear the graph if transitioning from workload to simulation + if (workload == true) { + points = []; + simulationNumber = 0; + } + workload = false; + simulationNumber += 1; const dailyTotalCount = addArrays( resp.dailyReviewCount, @@ -203,15 +210,25 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html } finally { simulating = false; if (resp) { - points = Object.entries(resp.memorized).map(([dr, v]) => ({ - x: parseInt(dr), - timeCost: resp!.cost[dr], - memorized: v, - count: -1, - label: 1, - })); - + // Clear the graph if transitioning from simulation to workload + if (workload == false) { + points = []; + simulationNumber = 0; + } workload = true; + + simulationNumber += 1; + + points = points.concat( + Object.entries(resp.memorized).map(([dr, v]) => ({ + x: parseInt(dr), + timeCost: resp!.cost[dr], + memorized: v, + count: -1, + label: simulationNumber, + })), + ); + tableData = renderWorkloadChart( svg as SVGElement, bounds,