-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reports screen: Monthly search reports integrated!
- Loading branch information
1 parent
3a6fabc
commit ef049a2
Showing
10 changed files
with
427 additions
and
169 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 |
---|---|---|
@@ -1,44 +1,41 @@ | ||
import React from "react"; | ||
import {GenericCard} from "../cards/GenericCard"; | ||
import {Dimensions} from "react-native"; | ||
import SleepStore from "../../store/SleepStore"; | ||
import {Sleep} from "../../store/SleepStore"; | ||
import {Observer} from "mobx-react"; | ||
import {LineChart} from "react-native-chart-kit"; | ||
import {Text} from "native-base"; | ||
|
||
export const SleepLineChart = () => { | ||
export const SleepLineChart = ({sleeps}: {sleeps: Array<Sleep> | undefined }) => { | ||
return ( | ||
<Observer> | ||
{() => { | ||
let data = sleeps?.map((sleep) => sleep.cycle).filter((sleep) => (sleep != undefined)) | ||
if (!data || data.length == 0) { | ||
data = [0] | ||
} | ||
|
||
return ( | ||
<Observer> | ||
{() => { | ||
let data = SleepStore.getSleeps(undefined, 30)?.map((sleep) => sleep.cycle).filter((sleep) => (sleep != undefined)) | ||
if (!data) { | ||
data = [0] | ||
} | ||
if (data.length == 0) { | ||
data = [0] | ||
} | ||
return ( | ||
<GenericCard style={{marginVertical: 10, backgroundColor: "#440e6a", marginTop: 5}}> | ||
<Text color="white" fontSize="md" bold textAlign="center">Sleep Cycles (last 30 days)</Text> | ||
<LineChart | ||
data={{datasets: [{data}]}} | ||
width={Dimensions.get("window").width} | ||
height={Dimensions.get("window").height / 3} | ||
yLabelsOffset={5} | ||
yAxisSuffix = " Cycles" | ||
chartConfig={{ | ||
backgroundGradientFrom: "#440e6a", | ||
backgroundGradientTo: "#440e6a", | ||
decimalPlaces: 0, | ||
color: (opacity = 1) => `rgba(255, 255, 255, ${opacity})`, | ||
labelColor: (opacity = 1) => `rgba(255, 255, 255, ${opacity})`, | ||
}} | ||
bezier | ||
style={{borderRadius: 20}} | ||
/> | ||
</GenericCard>); | ||
}} | ||
</Observer> | ||
); | ||
return ( | ||
<GenericCard style={{marginVertical: 10, backgroundColor: "#440e6a", marginTop: 5}}> | ||
<Text color="white" fontSize="md" bold textAlign="center">Sleep Cycles</Text> | ||
<LineChart | ||
data={{datasets: [{data: data as number[]}], labels: []}} | ||
width={Dimensions.get("window").width} | ||
height={Dimensions.get("window").height / 3} | ||
yLabelsOffset={5} | ||
yAxisSuffix=" Cycles" | ||
chartConfig={{ | ||
backgroundGradientFrom: "#440e6a", | ||
backgroundGradientTo: "#440e6a", | ||
decimalPlaces: 0, | ||
color: (opacity = 1) => `rgba(255, 255, 255, ${opacity})`, | ||
labelColor: (opacity = 1) => `rgba(255, 255, 255, ${opacity})`, | ||
}} | ||
bezier | ||
style={{borderRadius: 20}} | ||
/> | ||
</GenericCard>); | ||
}} | ||
</Observer> | ||
); | ||
}; |
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
Oops, something went wrong.