Created the stats page where a user can select another user to view their stats;
Improved the whole stats and the home page
This commit is contained in:
@@ -2,32 +2,29 @@ import {SEMI_TRANSPARENT} from "@/resources/colors";
|
||||
import {Chart as ChartJS, RadialLinearScale, ArcElement, Tooltip, Legend} from "chart.js";
|
||||
import clsx from "clsx";
|
||||
import {PolarArea} from "react-chartjs-2";
|
||||
import {Chart} from "primereact/chart";
|
||||
|
||||
interface Props {
|
||||
data: {label: string; value: number}[];
|
||||
label?: string;
|
||||
title: string;
|
||||
className?: string;
|
||||
type: string;
|
||||
}
|
||||
|
||||
ChartJS.register(RadialLinearScale, ArcElement, Tooltip, Legend);
|
||||
|
||||
export default function UserResultChart({data, title, className = ""}: Props) {
|
||||
export default function UserResultChart({data, type, label, title}: Props) {
|
||||
const labels = data.map((x) => x.label);
|
||||
const chartData = {
|
||||
labels,
|
||||
datasets: [
|
||||
{
|
||||
title,
|
||||
label,
|
||||
data: data.map((x) => x.value),
|
||||
backgroundColor: Object.values(SEMI_TRANSPARENT),
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={clsx("flex flex-col gap-4 items-center", className)}>
|
||||
<PolarArea data={chartData} options={{plugins: {title: {text: title, display: true}}}} />
|
||||
<h2 className="text-neutral-600 font-semibold text-lg">{title}</h2>
|
||||
</div>
|
||||
);
|
||||
return <Chart type={type} data={chartData} options={{plugins: {title: {text: title, display: true}}}} />;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user