|
1 | 1 | import React, { useEffect, useState} from 'react'; |
2 | | -import {Paper} from "@mui/material"; |
| 2 | +import {Paper, Typography} from "@mui/material"; |
3 | 3 | import useAxios from "../Hooks/useAxios.hook"; |
4 | | -import {CartesianGrid, Legend, Line, LineChart, Tooltip, XAxis, YAxis} from 'recharts'; |
| 4 | +import {CartesianGrid, Legend, Line, BarChart,Bar, Tooltip, XAxis, YAxis, ResponsiveContainer} from 'recharts'; |
5 | 5 |
|
6 | 6 | function Charts() { |
7 | | - const [data, setData] = useState(); |
8 | | - let url = "boulder"; |
9 | | - const [ response, isLoading, isError ] = useAxios(url); |
| 7 | + // const [data1, setData] = useState(); |
| 8 | + // let url = "progress"; |
| 9 | + // const [ response, isLoading, isError ] = useAxios(url); |
10 | 10 |
|
11 | | - useEffect(() => { |
12 | | - setData(response) |
| 11 | + // const [data2, setData] = useState(); |
| 12 | + // let url = "boulder"; |
| 13 | + // const [ response, isLoading, isError ] = useAxios(url); |
| 14 | + |
| 15 | + // const [data3, setData] = useState(); |
| 16 | + // let url = "ratings"; |
| 17 | + // const [ response, isLoading, isError ] = useAxios(url); |
| 18 | + |
| 19 | + // useEffect(() => { |
| 20 | + // setData(response) |
| 21 | + // |
| 22 | + // }, [url]); |
| 23 | + |
| 24 | + const testdata = [ |
| 25 | + { |
| 26 | + "Boulder": "01", |
| 27 | + "pv": 2 |
| 28 | + }, |
| 29 | + { |
| 30 | + "Boulder": "02", |
| 31 | + "pv": 8 |
| 32 | + }, |
| 33 | + { |
| 34 | + "Boulder": "03", |
| 35 | + "pv": 9 |
| 36 | + }, |
| 37 | + { |
| 38 | + "Boulder": "04", |
| 39 | + "pv": 3 |
| 40 | + }, |
| 41 | + { |
| 42 | + "Boulder": "05", |
| 43 | + "pv": 4 |
| 44 | + }, |
| 45 | + { |
| 46 | + "Boulder": "06", |
| 47 | + "pv": 8 |
| 48 | + }, |
| 49 | + { |
| 50 | + "Boulder": "07", |
| 51 | + "pv": 3 |
| 52 | + } |
| 53 | + ] |
13 | 54 |
|
14 | | - }, [url]); |
15 | 55 |
|
16 | 56 | return( |
| 57 | + |
17 | 58 | <Paper> |
18 | | - <LineChart width={730} height={250} data={data}> |
19 | | - <CartesianGrid strokeDasharray="3 3" /> |
20 | | - <XAxis dataKey="id" type="number"/> |
21 | | - <YAxis /> |
22 | | - <Tooltip /> |
23 | | - <Legend /> |
24 | | - <Line type="monotone" dataKey="difficulty" stroke="#8884d8" /> |
25 | | - </LineChart> |
| 59 | + <Typography align="center"> |
| 60 | + <h2>Completed Bolder</h2> |
| 61 | + |
| 62 | + </Typography> |
| 63 | + <ResponsiveContainer width='100%' height={400}> |
| 64 | + <BarChart width={700} height={250} data={testdata} margin={{ top: 20, right: 50, left: 20, bottom: 20 }}> |
| 65 | + <CartesianGrid strokeDasharray="3 3" /> |
| 66 | + <XAxis dataKey="Boulder" /> |
| 67 | + <YAxis /> |
| 68 | + <Tooltip /> |
| 69 | + <Legend /> |
| 70 | + <Bar dataKey="pv" fill="#8884d8" name="Completed"/> |
| 71 | + </BarChart> |
| 72 | + </ResponsiveContainer> |
| 73 | + |
| 74 | + <Typography align="center"> |
| 75 | + <h2>Difficulty of the Bolder</h2> |
| 76 | + |
| 77 | + </Typography> |
| 78 | + <ResponsiveContainer width='100%' height={400}> |
| 79 | + <BarChart width={700} height={250} data={testdata} margin={{ top: 20, right: 50, left: 20, bottom: 20 }}> |
| 80 | + <CartesianGrid strokeDasharray="3 3" /> |
| 81 | + <XAxis dataKey="Boulder" /> |
| 82 | + <YAxis /> |
| 83 | + <Tooltip /> |
| 84 | + <Legend /> |
| 85 | + <Bar dataKey="pv" fill="#8884d8" name="Difficulty"/> |
| 86 | + </BarChart> |
| 87 | + </ResponsiveContainer> |
| 88 | + |
| 89 | + <Typography align="center"> |
| 90 | + <h2>Rating of the Bolder</h2> |
| 91 | + |
| 92 | + </Typography> |
| 93 | + <ResponsiveContainer width='100%' height={400}> |
| 94 | + <BarChart width={700} height={250} data={testdata} margin={{ top: 20, right: 50, left: 20, bottom: 20 }}> |
| 95 | + <CartesianGrid strokeDasharray="3 3" /> |
| 96 | + <XAxis dataKey="Boulder" /> |
| 97 | + <YAxis /> |
| 98 | + <Tooltip /> |
| 99 | + <Legend /> |
| 100 | + <Bar dataKey="pv" fill="#8884d8" name="Rating of the Bolder" /> |
| 101 | + </BarChart> |
| 102 | + </ResponsiveContainer> |
26 | 103 | </Paper> |
27 | 104 | ) |
28 | 105 | } |
|
0 commit comments