React-native-chart-kit: How to hide Y-axis label and shadow line

Created on 20 Mar 2019  路  6Comments  路  Source: indiespirit/react-native-chart-kit

Hello Hermanya,
I use the LineChart,It looks like this.
寰俊鍥剧墖_20190320164211
Code:

 <LineChart
          data={{
                    labels: ['01', '02', '03', '04'],
                    datasets: [{
                        data: [
                            Math.random() * 100,
                            Math.random() * 100,
                            Math.random() * 100,
                            Math.random() * 100
                        ],
                        color: (opacity = 1) => `rgba(19, 155, 255, ${opacity})`
                    }]
                }}
                width={Dimensions.get('window').width} // from react-native
                height={220}
                withShadow={false}
                withOuterLines={false}
                chartConfig={{
                    withShadow: false,
                    withOuterLines: false,
                    backgroundColor: '#fff',
                    backgroundGradientFrom: '#fff',
                    backgroundGradientTo: '#fff',
                    decimalPlaces: 2, // optional, defaults to 2dp
                    color: (opacity = 1) => `rgba(90, 90, 90, ${opacity})`,
                    style: {
                        borderRadius: 16
                    }
                }}
                bezier
                style={{
                    marginVertical: 8,
                    borderRadius: 16
                }}
            />

I want to hide Y-axis label and shadow line,like this (tootip is not belong to chart)
寰俊鍥剧墖_20190320165125
can you help me

Most helpful comment

@azui007 @zanona

Hey guys, taking a look at the source, there is a default paddingRight of 64 if it is not provided in the style prop. So you can set paddingRight to 0 explicitly to get your expected result. I ran into this same problem just now, here's my graph:

image

And the code:

<Linechart
..some props
style={{ paddingRight: 0 }}
/>

All 6 comments

Did you find a solution? I need exactly the same thing: to hide labels completely.

There is no out of the box solution for this, but I would welcome a PR.

you can usewithHorizontalLabels={false}as a property to your LineChart element

and inside chartConfig use

propsForBackgroundLines:{
                      stroke:"#ffffff"
                    }

or equal to your background color

withHorizontalLabels={false} is not working with StackedBarChart

withHorizontalLabels={false} works on LineChart however it still leaves an empty space to the left of the chart. Ideally, disabling it, would also extend the chart to use the entire available width.

@azui007 @zanona

Hey guys, taking a look at the source, there is a default paddingRight of 64 if it is not provided in the style prop. So you can set paddingRight to 0 explicitly to get your expected result. I ran into this same problem just now, here's my graph:

image

And the code:

<Linechart
..some props
style={{ paddingRight: 0 }}
/>
Was this page helpful?
0 / 5 - 0 ratings

Related issues

bhoomika911 picture bhoomika911  路  4Comments

NS-BOBBY-C picture NS-BOBBY-C  路  5Comments

violabg picture violabg  路  6Comments

stebogit picture stebogit  路  3Comments

ighormartins picture ighormartins  路  3Comments