From 9f987a613abc1eb1429c24481c8fa4a35a0588ce Mon Sep 17 00:00:00 2001 From: Yen Cheng <92412722+ridemountainpig@users.noreply.github.com> Date: Thu, 17 Aug 2023 20:22:35 +0800 Subject: [PATCH] impr(result): display input history heatmap in the selected speed unit (ridemountainpig) (#4542) --- frontend/src/ts/test/result.ts | 1 + frontend/src/ts/test/test-ui.ts | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/frontend/src/ts/test/result.ts b/frontend/src/ts/test/result.ts index f489f49ed..83f68f1dd 100644 --- a/frontend/src/ts/test/result.ts +++ b/frontend/src/ts/test/result.ts @@ -888,6 +888,7 @@ ConfigEvent.subscribe(async (eventKey) => { updateWpmAndAcc(); await updateGraph(); await updateGraphPBLine(); + TestUI.applyBurstHeatmap(); ((ChartController.result.options as PluginChartOptions<"line" | "scatter">) .plugins.annotation.annotations as AnnotationOptions<"line">[]) = diff --git a/frontend/src/ts/test/test-ui.ts b/frontend/src/ts/test/test-ui.ts index 4376c49cc..fbcd9dd44 100644 --- a/frontend/src/ts/test/test-ui.ts +++ b/frontend/src/ts/test/test-ui.ts @@ -1080,6 +1080,11 @@ export async function applyBurstHeatmap(): Promise { burstlist = burstlist.filter((x) => x !== Infinity); burstlist = burstlist.filter((x) => x < 350); + const typingSpeedUnit = getTypingSpeedUnit(Config.typingSpeedUnit); + burstlist.forEach((burst, index) => { + burstlist[index] = Math.round(typingSpeedUnit.fromWpm(burst)); + }); + if ( TestInput.input.getHistory(TestInput.input.getHistory().length - 1) ?.length !== TestWords.words.getCurrent()?.length @@ -1165,7 +1170,10 @@ export async function applyBurstHeatmap(): Promise { if (wordBurstAttr === undefined) { $(word).css("color", unreachedColor); } else { - const wordBurstVal = parseInt(wordBurstAttr); + let wordBurstVal = parseInt(wordBurstAttr as string); + wordBurstVal = Math.round( + getTypingSpeedUnit(Config.typingSpeedUnit).fromWpm(wordBurstVal) + ); steps.forEach((step) => { if (wordBurstVal >= step.val) { $(word).addClass("heatmapInherit");