From 3eecb31f62bd9ea7e2b5441ad80e851444e76143 Mon Sep 17 00:00:00 2001 From: zkldi <20380519+zkldi@users.noreply.github.com> Date: Wed, 2 Nov 2022 00:57:48 +0000 Subject: [PATCH] fix: remove bpi chart it doesn't look good, and lags. --- client/src/components/charts/IIDXBPIChart.tsx | 204 ------------------ .../components/IIDXScoreDropdownParts.tsx | 22 +- 2 files changed, 3 insertions(+), 223 deletions(-) delete mode 100644 client/src/components/charts/IIDXBPIChart.tsx diff --git a/client/src/components/charts/IIDXBPIChart.tsx b/client/src/components/charts/IIDXBPIChart.tsx deleted file mode 100644 index b1d3ce252..000000000 --- a/client/src/components/charts/IIDXBPIChart.tsx +++ /dev/null @@ -1,204 +0,0 @@ -import { GetGradeFromPercent } from "util/misc"; -import { ResponsiveLine } from "@nivo/line"; -import BPICell from "components/tables/cells/BPICell"; -import DeltaCell from "components/tables/cells/DeltaCell"; -import ScoreCell from "components/tables/cells/ScoreCell"; -import MiniTable from "components/tables/components/MiniTable"; -import Divider from "components/util/Divider"; -import React, { useMemo } from "react"; -import { PoyashiBPI } from "rg-stats"; -import { - ChartDocument, - COLOUR_SET, - GetGamePTConfig, - Grades, - IDStrings, - integer, - PBScoreDocument, - ScoreDocument, -} from "tachi-common"; -import ChartTooltip from "./ChartTooltip"; - -interface BPIValue { - exScore: integer; - bpi: number; - percent: number; - grade: Grades[IDStrings]; - gradeIndex: integer; - label: string | undefined; -} - -const BPIValues: Record = {}; - -export default function IIDXBPIChart({ - chart, - score, -}: { - chart: ChartDocument<"iidx:SP" | "iidx:DP">; - score: ScoreDocument<"iidx:SP" | "iidx:DP"> | PBScoreDocument<"iidx:SP" | "iidx:DP">; -}) { - const gptConfig = GetGamePTConfig("iidx", chart.playtype); - const grades = gptConfig.grades; - - const bpiValues = useMemo(() => { - if (BPIValues[chart.chartID]) { - return BPIValues[chart.chartID]; - } - const MAX = chart.data.notecount * 2; - - const arr: BPIValue[] = []; - for (let exScore = 0; exScore <= MAX; exScore++) { - const percent = (100 * exScore) / MAX; - - const bpi = PoyashiBPI.calculate( - exScore, - chart.data.kaidenAverage!, - chart.data.worldRecord!, - MAX, - chart.data.bpiCoefficient - ); - - if (bpi === -15) { - continue; - } - - const grade = GetGradeFromPercent("iidx", chart.playtype, percent); - - const labelArr = []; - - if (exScore === chart.data.kaidenAverage) { - labelArr.push("皆伝"); - } else if (exScore === chart.data.worldRecord) { - labelArr.push("WR"); - } else if (exScore === score.scoreData.score) { - labelArr.push("You"); - } - - const label = labelArr.length === 0 ? undefined : labelArr.join(", "); - - arr.push({ - exScore, - percent, - grade, - gradeIndex: grades.indexOf(grade), - bpi, - label, - }); - } - - BPIValues[chart.chartID] = arr; - return arr; - }, [chart.chartID]); - - return ( - <> -
- ({ - x: d.percent, - y: d.bpi, - other: d, - label: d.label, - })), - }, - ]} - margin={{ top: 30, bottom: 50, left: 50, right: 50 }} - xScale={{ type: "linear", min: bpiValues[0].percent }} - axisBottom={{ - format: (x) => - gptConfig.gradeBoundaries!.indexOf(x) === -1 - ? null - : gptConfig.grades[gptConfig.gradeBoundaries!.indexOf(x)], - tickValues: gptConfig.gradeBoundaries!, - }} - motionConfig="stiff" - crosshairType="bottom-left" - yScale={{ type: "linear", max: 110, min: -20 }} - axisLeft={{ format: (y) => `${y}BPI` }} - useMesh={true} - pointSize={0} - colors={[COLOUR_SET.vibrantBlue]} - theme={{ - background: "none", - textColor: "#ffffff", - grid: { - line: { - stroke: "#1c1c1c", - strokeWidth: 1, - }, - }, - }} - curve="natural" - enablePointLabel - pointLabel="label" - tooltip={(d) => ( - { - const mockScore = { - game: "iidx", - playtype: chart.playtype, - scoreData: { - score: p.data.other.exScore, - grade: p.data.other.grade, - gradeIndex: p.data.other.gradeIndex, - percent: p.data.other.percent, - }, - calculatedData: { - BPI: p.data.other.bpi, - }, - } as ScoreDocument<"iidx:SP" | "iidx:DP">; - - const exScoreDiff = score.scoreData.score - p.data.other.exScore; - const bpiDiff = Number( - (score.calculatedData.BPI! - p.data.other.bpi).toFixed(2) - ); - - return ( -
- - - - - - - - - - You {score.scoreData.score}{" "} - - {" | "} - {score.calculatedData.BPI!.toFixed(2)}{" "} - - -
- ); - }} - /> - )} - legends={[]} - enableArea - /> -
- - ); -} - -function FormatDiff({ diff }: { diff: number }) { - if (diff === 0) { - return (+{diff}); - } else if (diff < 0) { - return ({diff}); - } - - return (+{diff}); -} diff --git a/client/src/components/tables/dropdowns/components/IIDXScoreDropdownParts.tsx b/client/src/components/tables/dropdowns/components/IIDXScoreDropdownParts.tsx index 210d2566d..e578847c8 100644 --- a/client/src/components/tables/dropdowns/components/IIDXScoreDropdownParts.tsx +++ b/client/src/components/tables/dropdowns/components/IIDXScoreDropdownParts.tsx @@ -1,11 +1,9 @@ import { IsScore } from "util/asserts"; -import { IsNotNullish, IsNullish } from "util/misc"; -import IIDXBPIChart from "components/charts/IIDXBPIChart"; import IIDXLampChart from "components/charts/IIDXLampChart"; import SelectNav from "components/util/SelectNav"; import React, { useEffect, useState } from "react"; import { Nav } from "react-bootstrap"; -import { ChartDocument, PBScoreDocument, ScoreDocument } from "tachi-common"; +import { PBScoreDocument, ScoreDocument } from "tachi-common"; // export function ModsTable({ score }: { score: ScoreDocument<"iidx:SP" | "iidx:DP"> }) { // if (!score.scoreMeta.assist && !score.scoreMeta.random) { @@ -38,12 +36,10 @@ type LampTypes = "DAN_GAUGE" | "NORMAL" | "EASY" | "HARD" | "EX_HARD"; export function IIDXGraphsComponent({ score, - chart, }: { score: ScoreDocument<"iidx:SP" | "iidx:DP"> | PBScoreDocument<"iidx:SP" | "iidx:DP">; - chart: ChartDocument<"iidx:SP" | "iidx:DP">; }) { - const [lamp, setLamp] = useState(LampToKey(score)); + const [lamp, setLamp] = useState(LampToKey(score)); let gaugeStatus: "none" | "single" | "gsm" = "none"; @@ -51,8 +47,6 @@ export function IIDXGraphsComponent({ gaugeStatus = "gsm"; } else if (score.scoreData.hitMeta.gaugeHistory) { gaugeStatus = "single"; - } else if (IsNotNullish(score.calculatedData.BPI) && lamp !== "BPI") { - setLamp("BPI"); } const shouldDisable = (r: LampTypes) => { @@ -115,20 +109,10 @@ export function IIDXGraphsComponent({ > Ex Hard - - BPI -
- {lamp === "BPI" ? ( - - ) : gaugeStatus === "gsm" && lamp !== "DAN_GAUGE" ? ( + {gaugeStatus === "gsm" && lamp !== "DAN_GAUGE" ? ( ) : gaugeStatus === "single" ? (