React-native-svg-charts: XAxis and YAxis Values getting repeated

Created on 28 Nov 2018  路  3Comments  路  Source: JesperLekland/react-native-svg-charts

What is the problem?

XAxis and YAxis Values getting repeated

When does it happen?

Hi,
i am new to react native and i am trying to add some charts to my app, and i dont know why some labels are getting repeated

What platform?

  • [ ] iOS
  • [x] Android

React Native version: 0.57.5

Code to reproduce

render() {

    const data = [
        {
            value: 50,
            label: 'One',
        },
        {
            value: 10,
            label: 'Two',
        },
        {
            value: 40,
            label: 'Three',
        },
        {
            value: 95,
            label: 'Four',
        },

    ]
    return (
     <Container>

        <View style={{ flexDirection: 'column', height: 200, paddingVertical: 16 }}>

                <BarChart
                    style={{ flex: 1}}
                    data={data}
                    yAccessor={({ item }) => item.value}
                    svg={{ fill: 'rgba(134, 65, 244, 0.8)' }}
                    contentInset={{ top: 10, bottom: 10 }}
                    spacing={0.2}
                    gridMin={0}
                >
                    <Grid direction={Grid.Direction.HORIZONTAL}/>
                </BarChart>
                <XAxis
                    data={data}
                    scale={scale.scaleBand}
                    formatLabel={(_, index) => data[ index ].label}
                />
            </View>
            <View style={{ flexDirection: 'row', height: 200, paddingVertical: 16 }}>
                <YAxis
                    data={data}
                    yAccessor={({ index }) => index}
                    scale={scale.scaleBand}
                    contentInset={{ top: 10, bottom: 10 }}
                    spacing={0.2}
                    formatLabel={(_, index) => data[ index ].label}
                />
                <BarChart
                    style={{ flex: 1, marginLeft: 8 }}
                    data={data}
                    horizontal={true}
                    yAccessor={({ item }) => item.value}
                    svg={{ fill: 'rgba(134, 65, 244, 0.8)' }}
                    contentInset={{ top: 10, bottom: 10 }}
                    spacing={0.2}
                    gridMin={0}
                >
                    <Grid direction={Grid.Direction.VERTICAL}/>
                </BarChart>
            </View>
      </Container>
    );
  }

Most helpful comment

All 3 comments

Using the bar chart component, with the react native app with version 0.57.2 and the version of this library in 5.2.0 I got the same issue, the first label looks repeated in the XAxis as shown in the image below:
screen shot 2018-12-10 at 1 46 44 pm

Same issue. How to fix it?
screen shot 2018-12-14 at 10 04 59 am

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mafiusu picture mafiusu  路  3Comments

holtc picture holtc  路  4Comments

otusweb picture otusweb  路  6Comments

themathiou picture themathiou  路  3Comments

lotcz picture lotcz  路  3Comments