react-native-pathjs-charts
react-native-pathjs-charts copied to clipboard
Question: Is there a way to have the chart automatically flex to size of the container?
trafficstars
Sorry if I'm missing this in the documentation, but is there way to automatically have the chart expand to the size of the container its in?
Unfortunately, no. This library is based off of https://github.com/rsamec/react-pathjs-chart and that is based off of https://github.com/andreaferretti/paths-js and both of those assume the use of fixed-size positioning.
Assuming your container is a <View /> You can use the onLayout() event and then event.nativeEvent.layout.width and event.nativeEvent.layout.height; to get the size of the container. These sizes you pass back to the chart.
<View
onLayout={event => this.setState({width: event.nativeEvent.layout.width, height: event.nativeEvent.layout.height}) />