The x-axis labels could be a list of strings, right? At least that's what I have.
But I'm getting a
Warning: Failed prop type: Invalid prop
data[0]supplied toXAxis.
Because of XAxis.propTypes only allowing numbers and objects for the data array items.
If you agree, I'm willing to make a PR to fix this.
Would love for this to be fixed so date strings can be easily fed into the Xaxis 馃憤
if you need anything else than numbers you can use the xAccessor and yAccessor to correctly map it to numerical data. If dates are to be used you need the correct xScale/ yScale
i am using formatLabel={index => data[index].yourValue} to call an item in the array
As JesperLekland mentioned, xAccessor also works well:
<XAxis
style={{marginHorizontal: -10, height: xAxisHeight}}
data={data}
xAccessor={({item}) => item.date}
formatLabel={value => moment(value).format("DD-MM-YYYY")}
contentInset={{left: 30, right: 30}}
svg={{
fontSize: 10,
fill: 'black',
fontWeight: 'bold',
rotation: 20,
originY: 15,
y: 15
}}
/>
Most helpful comment
i am using
formatLabel={index => data[index].yourValue}to call an item in the array