Info
Info
const tabs = [
{ 'name' : 'Total', 'filterFunction' : noFilter, 'graphWidth' : width * 10 },
{ 'name' : 'Morning', 'filterFunction' : morningFilter, 'graphWidth' : width * 2},
{ 'name' : 'Evening', 'filterFunction' : eveningFilter, 'graphWidth' : width },
{ 'name' : 'Night', 'filterFunction' : nightFilter, 'graphWidth' : width },
]
const [ selectedTab, setSelectedTab ] = useState(0);
let listener;
setGraphData({
labels: label_set,
datasets: [{ data: ppm_values }]
});
max_ppm.current = Math.max(...ppm_values)
min_ppm.current = Math.min(...ppm_values)
setAvgValue(avg(ppm_values))
setMaxValue(max_ppm.current);
setMaxTime(label_set[ppm_values.indexOf(max_ppm.current)]);
setMinValue(min_ppm.current);
setMinTime(label_set[ppm_values.indexOf(min_ppm.current)]);
}
useEffect(() => {
if (!loading) return;
setGraphData({
labels: label_set,
datasets: [{ data: ppm_values }]
});
max_ppm.current = Math.max(...ppm_values)
min_ppm.current = Math.min(...ppm_values)
setAvgValue(avg(ppm_values))
setMaxValue(max_ppm.current);
setMaxTime(label_set[ppm_values.indexOf(max_ppm.current)]);
setMinValue(min_ppm.current);
setMinTime(label_set[ppm_values.indexOf(min_ppm.current)]);
if (loading) setLoading(false);
});
return () => {
listener();
};
}, []);
return (
<SafeAreaView style={styles.view}>
<Text style={styles.heading}>{heading}</Text>
<View style={styles.chart_container}>
<ScrollView
style={styles.scroll_view_container}
horizontal
showsHorizontalScrollIndicator={false}
>
{loading ?
setClickedDataPoint(index);
}}
withVerticalLabels={true}
withVerticalLines={true}
withHorizontalLabels={true}
withHorizontalLines={true}
height={300}
withDots={true}
yAxisLabel=""
yAxisSuffix=""
yAxisInterval={500}
chartConfig={{
backgroundColor: '#344050',
backgroundGradientFrom: '#466568',
backgroundGradientTo: "#466568",
decimalPlaces: 0,
color: (opacity = 1) => '#1C2735',
labelColor: (opacity = 1) => "#1C2735",
propsForDots: {
r: "4",
strokeWidth: "0",
}
}}
bezier
style={{
paddingRight: width * 0.1,
borderRadius : 15
}}
renderDotContent={({ x, y, index }) => {
if (index !== clickedDataPoint) return null;
return (
<TouchableOpacity key={index} >
<DataCard
x={x}
y={y}
ppm={graphData.datasets[0].data[index]}
time={graphData.labels[index]}
/>
</TouchableOpacity>
);
}}
segments={2}
/>
)}
</ScrollView>
<View style={styles.range_filter}>
)}
</View>
</View>
{ loading ? null : (
<View style={styles.additional_info}>
<View style={styles.info_row}>
</View>
<View style={styles.info_row}>
<Text style={styles.additional_info_text}>Maximum</Text>
<View style={{display : 'flex', alignItems : 'center', justifyContent : 'center'}}>
<Text style={styles.additional_info_text}>{maxValue+' ppm'}</Text>
<Text style={[styles.additional_info_text, {fontSize : fonts.small }]}>{'At
'+maxTime}</Text>
</View>
</View>
<View style={styles.info_row}>
<Text style={styles.additional_info_text}>Minimum</Text>
<View style={{display : 'flex', alignItems : 'center', justifyContent : 'center'}}>
<Text style={styles.additional_info_text}>{minValue+' ppm'}</Text>
<Text style={[styles.additional_info_text, {fontSize : fonts.small }]}>{'At
'+minTime}</Text>
</View>
</View>
</View>)}
</SafeAreaView>
);
};
},
heading: {
fontFamily: 'productsans_med',
fontSize: fonts.large,
color: '#50827e',
padding: width * 0.01
},
scroll_view_container: {
...shadowProps,
backgroundColor: '#1C2735',
minHeight: '22%',
borderWidth: 0,
borderColor: '#555555',
borderRadius: 15,
padding: width * 0.01,
paddingRight: 0,
display: 'flex',
flexGrow: 0,
},
chart_container : {
display : 'flex',
justifyContent : 'space-around',
height : height * 0.45,
},
range_filter : {
display : 'flex',
flexDirection : 'row',
alignItems : 'center',
justifyContent : 'space-around'
},
range_button : {
backgroundColor : '#43736d20',
padding : width * 0.03,
borderRadius : 15
},
range_button_selected : {
backgroundColor : '#43736d',
padding : width * 0.03,
borderRadius : 15
},
range_button_text : {
fontFamily : 'productsans',
fontSize : fonts.small
},
additional_info : {
display : 'flex',
width : width * 0.9,
paddingTop : width * 0.05,
flex : 1
},
additional_info_text : {
fontFamily : 'productsans',
color : '#bbccbb',
margin : width * 0.004,
fontSize : fonts.medium - 3
},
info_row : {
borderWidth : 0,
backgroundColor : '#43736d40',
paddingHorizontal : width * 0.04,
paddingVertical : width * 0.03,
borderRadius : 15,
margin : width * 0.01,
display : 'flex',
flexDirection : 'row',
alignItems : 'center',
justifyContent : 'space-between'
},
msg_box : {
backgroundColor : '#43736D',
padding : width * 0.02,
borderRadius : 15,
margin : width * 0.01
}
});