Skip to content
Snippets Groups Projects
Commit 39943b5f authored by Aymeric Chaumont's avatar Aymeric Chaumont
Browse files

update front graph component for time-dependance

parent e81b8ff8
Branches
No related tags found
2 merge requests!29Time dependence,!28improve front
Pipeline #43934 passed with warnings
...@@ -11,33 +11,19 @@ import { ...@@ -11,33 +11,19 @@ import {
} from "recharts"; } from "recharts";
import "../styles/Graph.css"; import "../styles/Graph.css";
export default function DailyGraph({ place }) { export default function Graph({ place, type }) {
const [day, min_time_hour, min_time_mn, max_time_hour, max_time_mn, interval] = [ const [data, setData] = React.useState(null);
3, 12, 0, 12, 40, 300,
];
const url =
process.env.REACT_APP_BASE_URL_BACK +
"/" +
place +
"/stats/" +
day +
"/" +
min_time_hour +
"/" +
min_time_mn +
"/" +
max_time_hour +
"/" +
max_time_mn +
"/" +
interval;
const [data, setData] = React.useState([]);
React.useEffect(() => { React.useEffect(() => {
axios.get(url).then((response) => { axios
.get(
`${process.env.REACT_APP_BASE_URL_BACK}/${encodeURIComponent(place)}/${encodeURIComponent(
type,
)}_graph`,
)
.then((response) => {
setData(response.data); setData(response.data);
}); });
}, [url]); }, []);
if (!data) return null; if (!data) return null;
const CustomTooltip = ({ active, payload }) => { const CustomTooltip = ({ active, payload }) => {
......
...@@ -2,5 +2,5 @@ export { default as Header } from "./Header"; ...@@ -2,5 +2,5 @@ export { default as Header } from "./Header";
export { default as Footer } from "./Footer"; export { default as Footer } from "./Footer";
export { default as Timetable } from "./Timetable"; export { default as Timetable } from "./Timetable";
export { default as WaitingTime } from "./WaitingTime"; export { default as WaitingTime } from "./WaitingTime";
export { default as DailyGraph } from "./Graph"; export { default as Graph } from "./Graph";
export { default as Comments } from "./Comments"; export { default as Comments } from "./Comments";
import React from "react"; import React from "react";
import { DailyGraph, WaitingTime, Comments } from "../components"; import { Graph, WaitingTime, Comments } from "../components";
import "../styles/restaurant.css"; import "../styles/restaurant.css";
...@@ -12,9 +12,10 @@ export default function RestaurantPage({ selection }) { ...@@ -12,9 +12,10 @@ export default function RestaurantPage({ selection }) {
<Comments place={selection.name} infos /> <Comments place={selection.name} infos />
<div className="restaurant-container" id="restaurant-main-page"> <div className="restaurant-container" id="restaurant-main-page">
<WaitingTime place={selection.name} /> <WaitingTime place={selection.name} />
<DailyGraph place={selection.name} /> <Graph place={selection.name} type="current" />
</div> </div>
<Comments place={selection.name} /> <Comments place={selection.name} />
{/*<Graph place={selection.name} type="avg" />*/}
</div> </div>
)} )}
</> </>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment