impr(result): display input history heatmap in the selected speed unit (ridemountainpig) (#4542)

This commit is contained in:
Yen Cheng 2023-08-17 20:22:35 +08:00 committed by Miodec
parent 9b65a314b9
commit 9f987a613a
2 changed files with 10 additions and 1 deletions

View file

@ -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">[]) =

View file

@ -1080,6 +1080,11 @@ export async function applyBurstHeatmap(): Promise<void> {
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<void> {
if (wordBurstAttr === undefined) {
$(word).css("color", unreachedColor);
} else {
const wordBurstVal = parseInt(<string>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");