diff --git a/frontend/components/molecules/lifterGraph.tsx b/frontend/components/molecules/lifterGraph.tsx index b0c61b05..d83eb8c7 100644 --- a/frontend/components/molecules/lifterGraph.tsx +++ b/frontend/components/molecules/lifterGraph.tsx @@ -8,7 +8,7 @@ import { Title, Tooltip, Legend, - ChartOptions + ChartOptions, } from 'chart.js' import { Line } from 'react-chartjs-2' @@ -19,74 +19,85 @@ ChartJS.register( LineElement, Title, Tooltip, - Legend + Legend, ) // todo: add a aspect ratio prop to the component -export const LifterGraph = ({ lifterHistory, setRatio }: { lifterHistory: LifterChartData | null, setRatio: number }) => { +const LifterGraph = ({ + lifterHistory, + setRatio, +}: { + lifterHistory: LifterChartData | null + setRatio: number +}) => { if (!lifterHistory) { - return null; + return null } // todo: define each dataset as a type/interface instead of manually indexing into the array const processedData = { labels: lifterHistory.labels, - datasets: [{ - ...lifterHistory.datasets[0], - borderColor: '#0072F5', - backgroundColor: '#3694FF' - }, { - ...lifterHistory.datasets[1], - borderColor: '#17C964', - backgroundColor: '#78F2AD' - }, { - ...lifterHistory.datasets[2], - borderColor: '#F31260', - backgroundColor: '#F75F94' - }, { - ...lifterHistory.datasets[3], - borderColor: '#F3A312', - backgroundColor: '#F7C78F' - }] + datasets: [ + { + ...lifterHistory.datasets[0], + borderColor: '#0072F5', + backgroundColor: '#3694FF', + }, + { + ...lifterHistory.datasets[1], + borderColor: '#17C964', + backgroundColor: '#78F2AD', + }, + { + ...lifterHistory.datasets[2], + borderColor: '#F31260', + backgroundColor: '#F75F94', + }, + { + ...lifterHistory.datasets[3], + borderColor: '#F3A312', + backgroundColor: '#F7C78F', + }, + ], } - /* todo: implement scales gridlines colour into the config - scales: { - x: {grid: {color: '#313538'}}, - y: {grid: {color: '#313538'}} + const config = { + plugins: { + legend: { + display: false, }, - */ - const config: ChartOptions = { - aspectRatio: setRatio, - color: 'white', - layout: { - padding: 20 }, - elements: { - point: { - radius: 4, - borderWidth: 0, - hitRadius: 2 + scales: { + x: { + grid: { + display: false, + }, + ticks: { + color: '#A0A0A0', + font: { + size: 12, + }, + }, }, - line: { - tension: 0.1, - borderCapStyle: 'round', - fill: false, - borderWidth: 2 - } - }, - plugins: { - legend: { - position: 'bottom', - labels: { - boxHeight: 15, - boxWidth: 15 + y: { + grid: { + color: '#F0F0F0', + borderColor: '#F0F0F0', + borderWidth: 1, }, - } + ticks: { + color: '#A0A0A0', + font: { + size: 12, + }, + }, + }, }, + maintainAspectRatio: false, + aspectRatio: setRatio, } - return ( - - ) -}; \ No newline at end of file + return +} + +export default LifterGraph diff --git a/frontend/components/molecules/lifterGraphModal.tsx b/frontend/components/molecules/lifterGraphModal.tsx index 446b30af..67bdc084 100644 --- a/frontend/components/molecules/lifterGraphModal.tsx +++ b/frontend/components/molecules/lifterGraphModal.tsx @@ -1,7 +1,7 @@ import useSWR from 'swr' import { Modal, ModalContent, ModalHeader, Spinner } from '@nextui-org/react' import fetchLifterGraphData from '@/api/fetchLifterGraphData/fetchLifterGraphData' -import { LifterGraph } from './lifterGraph' +import LifterGraph from './lifterGraph' function LifterGraphModal({ lifterName, diff --git a/frontend/components/organisms/lifterPage.tsx b/frontend/components/organisms/lifterPage.tsx index f03e94e1..2603456f 100644 --- a/frontend/components/organisms/lifterPage.tsx +++ b/frontend/components/organisms/lifterPage.tsx @@ -3,7 +3,7 @@ import { useRouter } from 'next/router' import { Spinner } from '@nextui-org/react' import { LifterStats } from '@/components/molecules/lifterStats' -import { LifterGraph } from '@/components/molecules/lifterGraph' +import LifterGraph from '@/components/molecules/lifterGraph' import { HistoryTable } from '@/components/molecules/historyTable' import fetchLifterHistory from '../../api/fetchLifterHistory/fetchLifterHistory' import HeaderBar from '@/components/molecules/head' @@ -15,10 +15,7 @@ function LifterPage() { params[key] = router.query[key]?.toString() || '' } - const { data, isLoading } = useSWR( - params, - fetchLifterHistory, - ) + const { data, isLoading } = useSWR(params, fetchLifterHistory) return ( <> diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 96e4b10b..99635855 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -14299,6 +14299,111 @@ "funding": { "url": "https://github.com/sponsors/sindresorhus" } + }, + "node_modules/@next/swc-darwin-arm64": { + "version": "14.2.14", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-14.2.14.tgz", + "integrity": "sha512-bsxbSAUodM1cjYeA4o6y7sp9wslvwjSkWw57t8DtC8Zig8aG8V6r+Yc05/9mDzLKcybb6EN85k1rJDnMKBd9Gw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-darwin-x64": { + "version": "14.2.14", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-14.2.14.tgz", + "integrity": "sha512-cC9/I+0+SK5L1k9J8CInahduTVWGMXhQoXFeNvF0uNs3Bt1Ub0Azb8JzTU9vNCr0hnaMqiWu/Z0S1hfKc3+dww==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm64-gnu": { + "version": "14.2.14", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-14.2.14.tgz", + "integrity": "sha512-RMLOdA2NU4O7w1PQ3Z9ft3PxD6Htl4uB2TJpocm+4jcllHySPkFaUIFacQ3Jekcg6w+LBaFvjSPthZHiPmiAUg==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm64-musl": { + "version": "14.2.14", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-14.2.14.tgz", + "integrity": "sha512-WgLOA4hT9EIP7jhlkPnvz49iSOMdZgDJVvbpb8WWzJv5wBD07M2wdJXLkDYIpZmCFfo/wPqFsFR4JS4V9KkQ2A==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-arm64-msvc": { + "version": "14.2.14", + "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-14.2.14.tgz", + "integrity": "sha512-8i0Ou5XjTLEje0oj0JiI0Xo9L/93ghFtAUYZ24jARSeTMXLUx8yFIdhS55mTExq5Tj4/dC2fJuaT4e3ySvXU1A==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-ia32-msvc": { + "version": "14.2.14", + "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-14.2.14.tgz", + "integrity": "sha512-2u2XcSaDEOj+96eXpyjHjtVPLhkAFw2nlaz83EPeuK4obF+HmtDJHqgR1dZB7Gb6V/d55FL26/lYVd0TwMgcOQ==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-x64-msvc": { + "version": "14.2.14", + "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.2.14.tgz", + "integrity": "sha512-MZom+OvZ1NZxuRovKt1ApevjiUJTcU2PmdJKL66xUPaJeRywnbGGRWUlaAOwunD6dX+pm83vj979NTC8QXjGWg==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } } } }