Hello, I have a line chart in my app that I would like to be clickable, but it appears I have an issue where the component keeps rendering/updating when clicked upon. At first I thought it had to do with setting state in the component so I removed it, but I am finding it behaving the same way even when the code is commented out. I assume the mistake I am making is something really small, as I am getting confused. Any help is truly appreciated! Please let me know if further clarification is needed.
<LineChart
dataSet={Array.isArray(data)? data: []}
noOfSections={5}
// rotateLabel
width={width*.84}
height={height*0.37}
// disableScroll
adjustToWidth
hideDataPoints
// spacing={10}
color="#00ff83"
thickness={2}
// startFillColor="rgba(20,105,81,0.3)"
// endFillColor="rgba(20,85,81,0.01)"
// startOpacity={0.9}
// endOpacity={0.2}
initialSpacing={0}
// maxValue={600}
yAxisColor="white"
yAxisThickness={0}
rulesType="solid"
rulesColor="gray"
yAxisTextStyle={{color: 'gray'}}
xAxisColor="lightgray"
pointerConfig={{
pointerStripColor: 'lightgray',
pointerStripWidth: 2,
pointerColor: 'lightgray',
radius: 6,
// pointerLabelWidth: 100,
// pointerLabelHeight: 90,
activatePointersOnLongPress: true,
autoAdjustPointerLabelPosition: false,
// shiftPointerLabelY: -20,
// pointerComponent: useCallback((items: LineData, index: number) => {
// if (items.date !== currentDate) {
// setCurrentDate(items.date);
// }
// if (items.value !== currentValues[items.name]) {
// const curVals: {} = {};
// for (let x in currentValues) {
// if (x === items.name) {
// curVals[items.name] = items.value;
// } else {
// curVals[x] = currentValues[x]
// }
// }
// setCurrentValues(curVals);
// }
// console.log(items)
// console.log(index)
// }, []),
// pointerLabelComponent: pointerLabelComponent,
pointerLabelComponent: items => {
console.log(items);
return (<></>);
// console.log(items)
// setCurrentDate(items[0].date);
// let curVals = {};
// items.map(item => {
// curVals[item.name] = item.value
// })
// setCurrentValues(curVals);
// console.log(curVals);
// return(<></>);
// return (
// <ThemedView
// style={{
// height: 90,
// width: 100,
// justifyContent: 'center',
// marginTop: -30,
// marginLeft: -40,
// }}
// >
// <Text style={{color: 'white', fontSize: 14, marginBottom:6,textAlign:'center'}}>
// {items[0].date}
// </Text>
// <ThemedView style={{paddingHorizontal:14,paddingVertical:6, borderRadius:16, backgroundColor:'white'}}>
// <Text style={{color: items[0].color}}>{items[0].name}</Text>
// <Text style={{fontWeight: 'bold',textAlign:'center'}}>
// {items[0].value + ' PSI'}
// </Text>
// </ThemedView>
// </ThemedView>
// );
},
}}
/>
Using the code included above.
Description
Hello, I have a line chart in my app that I would like to be clickable, but it appears I have an issue where the component keeps rendering/updating when clicked upon. At first I thought it had to do with setting state in the component so I removed it, but I am finding it behaving the same way even when the code is commented out. I assume the mistake I am making is something really small, as I am getting confused. Any help is truly appreciated! Please let me know if further clarification is needed.
Code:
(PS, the themed view is just like the regular view but styling is set)
Steps to reproduce
Using the code included above.
Snack or a link to a repository
No response
version of react-native-gifted-charts
1.4.74
React Native version
0.81.4
Platforms
Android
Workflow
None