fixed pb lines not working. closes #1712

This commit is contained in:
Jack 2021-08-08 17:16:19 +01:00
parent 6d2317b928
commit 6aaeaf4417
2 changed files with 42 additions and 8 deletions

View file

@ -624,6 +624,7 @@ export let miniResult = new Chart($(".pageAccount #miniResultChart"), {
});
export async function updateColors(chart) {
let bgcolor = await ThemeColors.get("bg");
let subcolor = await ThemeColors.get("sub");
let maincolor = await ThemeColors.get("main");
@ -679,6 +680,38 @@ export async function updateColors(chart) {
chart.data.datasets[1].trendlineLinear.style = subcolor;
} catch {}
try {
chart.options.annotation.annotations.forEach((annotation) => {
annotation.borderColor = subcolor;
annotation.label.backgroundColor = subcolor;
annotation.label.fontColor = bgcolor;
});
} catch {}
// ChartController.result.options.annotation.annotations.push({
// enabled: false,
// type: "line",
// mode: "horizontal",
// scaleID: "wpm",
// value: lpb,
// borderColor: themecolors['sub'],
// borderWidth: 1,
// borderDash: [2, 2],
// label: {
// backgroundColor: themecolors['sub'],
// fontFamily: Config.fontFamily.replace(/_/g, " "),
// fontSize: 11,
// fontStyle: "normal",
// fontColor: themecolors['bg'],
// xPadding: 6,
// yPadding: 6,
// cornerRadius: 3,
// position: "center",
// enabled: true,
// content: `PB: ${lpb}`,
// },
// });
chart.update({ duration: 250 });
}

View file

@ -1581,6 +1581,7 @@ export async function finish(difficultyFailed = false) {
);
}
}
let themecolors = await ThemeColors.get();
if (lpb > 0) {
ChartController.result.options.annotation.annotations.push({
enabled: false,
@ -1588,15 +1589,15 @@ export async function finish(difficultyFailed = false) {
mode: "horizontal",
scaleID: "wpm",
value: lpb,
borderColor: await ThemeColors.get("sub"),
borderColor: themecolors["sub"],
borderWidth: 1,
borderDash: [2, 2],
label: {
backgroundColor: await ThemeColors.get("sub"),
backgroundColor: themecolors["sub"],
fontFamily: Config.fontFamily.replace(/_/g, " "),
fontSize: 11,
fontStyle: "normal",
fontColor: await ThemeColors.get("bg"),
fontColor: themecolors["bg"],
xPadding: 6,
yPadding: 6,
cornerRadius: 3,
@ -1666,15 +1667,15 @@ export async function finish(difficultyFailed = false) {
mode: "horizontal",
scaleID: "wpm",
value: tpb,
borderColor: await ThemeColors.get("sub"),
borderColor: themecolors["sub"],
borderWidth: 1,
borderDash: [2, 2],
label: {
backgroundColor: await ThemeColors.get("sub"),
backgroundColor: themecolors["sub"],
fontFamily: Config.fontFamily.replace(/_/g, " "),
fontSize: 11,
fontStyle: "normal",
fontColor: await ThemeColors.get("bg"),
fontColor: themecolors["bg"],
xPadding: 6,
yPadding: 6,
cornerRadius: 3,
@ -1949,7 +1950,7 @@ export async function finish(difficultyFailed = false) {
} else {
$("#result .stats .source").addClass("hidden");
}
let fc = await ThemeColors.get("sub");
if (Config.funbox !== "none") {
let content = Config.funbox;
if (Config.funbox === "layoutfluid") {
@ -1969,7 +1970,7 @@ export async function finish(difficultyFailed = false) {
fontFamily: Config.fontFamily.replace(/_/g, " "),
fontSize: 11,
fontStyle: "normal",
fontColor: await ThemeColors.get("sub"),
fontColor: fc,
xPadding: 6,
yPadding: 6,
cornerRadius: 3,