-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vinvoor: show the user's most common days
- Loading branch information
Showing
5 changed files
with
74 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { ApexOptions } from "apexcharts"; | ||
import { useContext } from "react"; | ||
import Chart from "react-apexcharts"; | ||
import { Scan } from "../../types/scans"; | ||
import { ScanContext } from "../Overview"; | ||
|
||
const getDayCount = (scans: readonly Scan[]) => { | ||
const days = [0, 0, 0, 0, 0, 0, 0]; | ||
scans.forEach((scan) => { | ||
days[scan.scanTime.getDay() - 1]++; | ||
}); | ||
return days.slice(0, -2); | ||
}; | ||
|
||
export const Days = () => { | ||
const { scans } = useContext(ScanContext); | ||
|
||
const state = { | ||
options: { | ||
labels: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"], | ||
fill: { | ||
opacity: 1, | ||
}, | ||
yaxis: { | ||
show: false, | ||
}, | ||
legend: { | ||
position: "bottom", | ||
labels: { | ||
useSeriesColors: true, | ||
}, | ||
}, | ||
plotOptions: { | ||
polarArea: { | ||
rings: { | ||
strokeWidth: 0, | ||
}, | ||
spokes: { | ||
strokeWidth: 0, | ||
}, | ||
}, | ||
}, | ||
theme: { | ||
monochrome: { | ||
enabled: true, | ||
color: "#ff7f00", | ||
shadeTo: "light", | ||
shadeIntensity: 1, | ||
}, | ||
}, | ||
} as ApexOptions, | ||
series: getDayCount(scans), | ||
}; | ||
|
||
return ( | ||
<Chart options={state.options} series={state.series} type="polarArea" /> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters