-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75 from qlemaire22/add-player-statistics-page
Add player statistics page
- Loading branch information
Showing
15 changed files
with
265 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { createEffect, createSignal, onMount } from "solid-js" | ||
import { SelectButton, type SelectButtonOption } from "../ui/SelectButton" | ||
import infernals from "../../assets/game/factions/infernals-small-glow.png" | ||
import vanguard from "../../assets/game/factions/vanguard-small-glow.png" | ||
import { Race } from "../../lib/api" | ||
|
||
const factionOptions: SelectButtonOption[] = [ | ||
{ | ||
label: "Infernals", | ||
value: Race.INFERNALS, | ||
icon: infernals.src, | ||
}, | ||
{ label: "Vanguard", value: Race.VANGUARD, icon: vanguard.src }, | ||
] | ||
|
||
export function FactionDropdown(props: { queryParam: string; selected: (typeof factionOptions)[number]["value"] }) { | ||
const selected = props.selected ?? "all" | ||
const [faction, setFaction] = createSignal( | ||
factionOptions.find((option) => option.value === selected) || factionOptions[0] | ||
) | ||
|
||
createEffect(() => { | ||
const urlParams = new URLSearchParams(window.location.search) | ||
if (faction()?.value === selected) return | ||
if (faction()?.value && faction()?.value != "all") urlParams.set(props.queryParam, faction()?.value!) | ||
else urlParams.delete(props.queryParam) | ||
window.location.href = `${window.location.pathname}${urlParams.size ? "?" + urlParams.toString() : ""}` | ||
}) | ||
|
||
return <SelectButton options={factionOptions} value={faction} setValue={setFaction} /> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// @ts-nocheck | ||
|
||
import { onMount } from "solid-js" | ||
import { Chart, Title, Tooltip, Colors, TimeScale, type ChartOptions, type ChartData } from "chart.js" | ||
import { Line } from "solid-chartjs" | ||
import "chartjs-adapter-date-fns" | ||
|
||
type MmrHistoryChartProps = { | ||
labels: string[] | ||
data: number[] | ||
} | ||
|
||
const longNumberFormatter = new Intl.NumberFormat("en-us") | ||
|
||
export function MmrHistoryChart(props: MmrHistoryChartProps) { | ||
let canvas: HTMLCanvasElement | ||
onMount(() => { | ||
Chart.register(Title, Tooltip, Colors, TimeScale) | ||
}) | ||
|
||
const chartData: ChartData = { | ||
labels: props.labels, | ||
datasets: [ | ||
{ | ||
label: "MMR", | ||
data: props.data, | ||
tension: 0.3, | ||
borderColor: "#9E9E9E", | ||
pointRadius: 5, | ||
pointHoverRadius: 2, | ||
pointBorderColor: "transparent", | ||
}, | ||
], | ||
} | ||
|
||
const chartOptions: ChartOptions = { | ||
responsive: true, | ||
maintainAspectRatio: true, | ||
interaction: { | ||
intersect: false, | ||
mode: "index", | ||
}, | ||
scales: { | ||
y: { | ||
ticks: { | ||
precision: 0, | ||
}, | ||
offset: true, | ||
}, | ||
x: { | ||
type: "time", | ||
time: { unit: "day", tooltipFormat: "d MMM, y" }, | ||
}, | ||
}, | ||
plugins: { | ||
tooltip: { | ||
displayColors: false, | ||
callbacks: { | ||
label: (c) => `MMR: ${Math.round(c.parsed.y)}`, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
return ( | ||
<div class="relative w-full overflow-hidden"> | ||
<Line data={chartData} options={chartOptions} height={100} width={300} ref={(c) => (canvas = c)} /> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,5 +5,4 @@ | |
export enum Race { | ||
INFERNALS = "infernals", | ||
VANGUARD = "vanguard", | ||
RANDOM = "random", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* generated using openapi-typescript-codegen -- do no edit */ | ||
/* istanbul ignore file */ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
export enum Resolution { | ||
MINUTE = "minute", | ||
HOUR = "hour", | ||
DAY = "day", | ||
WEEK = "week", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.