mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2026-01-14 11:24:11 +08:00
fix tribe charts looking different than the main chart
This commit is contained in:
parent
6e0971f829
commit
e328448fd3
1 changed files with 21 additions and 9 deletions
|
|
@ -6,6 +6,8 @@ import { createErrorMessage } from "../utils/misc";
|
|||
import tribeSocket from "./tribe-socket";
|
||||
import { blendTwoHexColors } from "../utils/colors";
|
||||
import { smoothWithValueWindow } from "../utils/arrays";
|
||||
import Config from "../config";
|
||||
import * as TestStats from "../test/test-stats";
|
||||
|
||||
const charts: Record<string, Chart> = {};
|
||||
|
||||
|
|
@ -298,23 +300,33 @@ async function fillData(chart: Chart, userId: string): Promise<void> {
|
|||
scale.title.color = subcolor;
|
||||
}
|
||||
|
||||
const wpmToShow = [...result.chartData.wpm];
|
||||
const burstToShow = [...result.chartData.burst];
|
||||
const errToShow = [...result.chartData.err];
|
||||
|
||||
const valueWindow = Math.max(...burstToShow) * 0.25;
|
||||
const smoothedBurst = smoothWithValueWindow(burstToShow, 1, valueWindow);
|
||||
|
||||
if (
|
||||
Config.mode !== "time" &&
|
||||
TestStats.lastSecondNotRound &&
|
||||
result.testDuration % 1 < 0.5
|
||||
) {
|
||||
labels.pop();
|
||||
wpmToShow.pop();
|
||||
errToShow.pop();
|
||||
}
|
||||
|
||||
const c = chart as unknown as typeof settings;
|
||||
|
||||
c.data.labels = labels;
|
||||
//@ts-expect-error tribe
|
||||
c.data.datasets[0].data = result.chartData.wpm;
|
||||
|
||||
const valueWindow = Math.max(...result.chartData.burst) * 0.25;
|
||||
const smoothedBurst = smoothWithValueWindow(
|
||||
result.chartData.burst,
|
||||
1,
|
||||
valueWindow,
|
||||
);
|
||||
c.data.datasets[0].data = wpmToShow;
|
||||
|
||||
//@ts-expect-error tribe
|
||||
chart.data.datasets[1].data = smoothedBurst;
|
||||
//@ts-expect-error tribe
|
||||
chart.data.datasets[2].data = result.chartData.err;
|
||||
chart.data.datasets[2].data = errToShow;
|
||||
|
||||
const wpm = chart.data.datasets[0] as ChartDataset;
|
||||
const burst = chart.data.datasets[1] as ChartDataset;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue