Reputation: 1237
I am using react-native-svg-charts to show pie charts and bar charts in react-native, in bar charts, X-axis labels overlap or doesn't display.
how can render text content in X-axis in bar charts
this is my code
<XAxis
style={{flex:1,height: windowSize.width/1.875, paddingTop:10 }}
data={data2}
formatLabel={value => {
return data2.map(item => {
return `${item}\n`;
});
}}
contentInset={{ left: 30, right: 30 }}
svg={{ fontSize: 10, fill: '#3A8F98' }}
/>
Upvotes: 1
Views: 7356
Reputation: 1237
<XAxis
style={{ paddingTop: 10,backgroundColor:'red' }}
data={data}
formatLabel={(value, index) => this.state.data2[index]}
contentInset={{ left: 18, right: 18 }}
svg={{ fontSize: windowSize.width/55, fill: '#3A8F98' }}/>
changed the formatLabel from
formatLabel={value => {return data2.map(item => {
return `${item}\n`;
});
}}
to
formatLabel={(value, index) => this.state.data2[index]}
Upvotes: 3
Reputation: 2424
You can rotate the labels using the rotation
svg attribute.
<XAxis
data={data}
svg={{ rotation: 30 }}
/>
Upvotes: 2