-
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.
Merge pull request #287 from COS301-SE-2024/feat/mobile/occupancy-int…
…egration Feat/mobile/occupancy integration
- Loading branch information
Showing
28 changed files
with
942 additions
and
1,095 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import React, { useEffect, useState } from 'react' | ||
import { widthPercentageToDP as wp, heightPercentageToDP as hp } from 'react-native-responsive-screen'; | ||
import { | ||
View, | ||
} from '@gluestack-ui/themed'; | ||
import * as SecureStore from 'expo-secure-store'; | ||
import { LineChart } from "react-native-gifted-charts" | ||
import { useColorScheme } from 'react-native'; | ||
import { useTheme } from './ThemeContext'; | ||
|
||
const LineGraph = (data) => { | ||
const colorscheme = useColorScheme(); | ||
const { theme } = useTheme(); | ||
const currentTheme = theme === "system" ? colorscheme : theme; | ||
// console.log(data.data); | ||
const labels = currentTheme === 'dark' ? "lightgray" : "darkgrey"; | ||
const [accentColour, setAccentColour] = useState<string>('greenyellow'); | ||
useEffect(() => { | ||
const getAccentColour = async () => { | ||
let accentcolour = await SecureStore.getItemAsync('accentColour'); | ||
setAccentColour(accentcolour); | ||
}; | ||
getAccentColour(); | ||
}, []); | ||
return ( | ||
<View | ||
style={{ width: wp('100%'), height: hp('35%'), flexDirection: 'column' }} | ||
// style={{ | ||
// // marginVertical: 100, | ||
// paddingVertical: 20, | ||
// backgroundColor: '#414141', | ||
// }} | ||
> | ||
<LineChart | ||
isAnimated | ||
width={wp('80%')} | ||
thickness={3} | ||
color={accentColour} | ||
maxValue={5} | ||
noOfSections={5} | ||
// hideRules | ||
animateOnDataChange | ||
animationDuration={1000} | ||
onDataChangeAnimationDuration={300} | ||
areaChart | ||
endSpacing={0} | ||
yAxisTextStyle={{color: labels}} | ||
xAxisLabelTextStyle={{color: labels}} | ||
data={data.data} | ||
hideDataPoints | ||
startFillColor={accentColour} | ||
endFillColor={accentColour} | ||
startOpacity={0.5} | ||
endOpacity={0.1} | ||
spacing={47} | ||
backgroundColor={currentTheme === 'dark' ? "#414141" : "white"} | ||
// showVerticalLines | ||
// verticalLinesColor="rgba(14,164,164,0.5)" | ||
// rulesColor="gray" | ||
rulesType="dashed" | ||
initialSpacing={20} | ||
yAxisColor={currentTheme === 'dark' ? "lightgray" : "darkgrey"} | ||
xAxisColor={currentTheme === 'dark' ? "lightgray" : "darkgrey"} | ||
/> | ||
</View> | ||
) | ||
} | ||
|
||
export default LineGraph |
Oops, something went wrong.