Skip to content

Commit

Permalink
Merge pull request #97 from Franpastoragusti/graph-to-highcharts
Browse files Browse the repository at this point in the history
fix x periods
  • Loading branch information
escottalexander authored Jul 25, 2024
2 parents 6adb45a + 44fb4c4 commit 1139453
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const LeaderBoardComponent = () => {
return;
}
if (val != "" && valEnd != "") {
getScores(`${val},${valEnd}`);
getScores(`${startDate},${endDate}`);
}
}, [startDate, endDate]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ export const ProjectTotalsGraph = ({
totalsRecord,
filter,
}: IProps) => {
const intFilter = parseInt(filter) >= 60 ? 30 : parseInt(filter) > 7 ? 7 : 1;
const tickInterval = 24 * 3600 * 1000;
const options = {
chart: {
type: "line",
Expand All @@ -49,6 +51,7 @@ export const ProjectTotalsGraph = ({
},
xAxis: {
type: "datetime",
tickInterval: intFilter * tickInterval,
title: {
text: "",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ export const GlobalScoreService = () => {
const baseURL = `${process.env.NEXT_PUBLIC_API_URL}/globalScore`;
const getGlobalScores = async (filter?: string) => {
let url = `${baseURL}`;
let startDate = new Date();
let endDate = new Date();
if (filter) {
if (filter.includes(",")) {
const [start, end] = filter.split(",");
url += `?startDate=${start}&endDate=${end}`;
startDate = new Date(start);
endDate = new Date(end);
} else if (typeof parseInt(filter) === "number") {
const startDate = new Date();
startDate.setDate(startDate.getDate() - parseInt(filter));
const endDate = new Date();
url += `?startDate=${startDate.toISOString()}&endDate=${endDate.toISOString()}`;
}
url += `?startDate=${startDate.toISOString()}&endDate=${endDate.toISOString()}`;
}
const response = await fetch(url);
const { data }: { data: IGlobalScore[] } = await response.json();
Expand Down

0 comments on commit 1139453

Please sign in to comment.