react-native-pathjs-charts icon indicating copy to clipboard operation
react-native-pathjs-charts copied to clipboard

Question: Is there a way to have the chart automatically flex to size of the container?

Open timfpark opened this issue 8 years ago • 2 comments
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?

timfpark avatar Jul 28 '17 22:07 timfpark

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.

marzolfb avatar Jul 30 '17 04:07 marzolfb

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}) />

Stophface avatar Oct 26 '17 12:10 Stophface