Giter Club home page Giter Club logo

Comments (7)

verofy-simon-denny avatar verofy-simon-denny commented on June 1, 2024 1

Thanks that works now.

from react-native-gifted-charts.

verofy-simon-denny avatar verofy-simon-denny commented on June 1, 2024

Sorry, also, is there a way that we can set the space on the left of the chart to 0 for times when we don't want the y axis showing?

from react-native-gifted-charts.

Abhinandan-Kushwaha avatar Abhinandan-Kushwaha commented on June 1, 2024

Hi @verofy-simon-denny πŸ‘‹

Regarding your first question -

Yes, we can remove the extra padding at the top, by using the maxValue prop.

Here's a chart without using the maxValue prop-
padding
The code for the above chart is -

const barData = [{value: 15}, {value: 30}, {value: 26}, {value: 40}];
<BarChart backgroundColor={'red'} data={barData} />

Now, if we add maxValue={40} -

const barData = [{value: 15}, {value: 30}, {value: 26}, {value: 40}];
<BarChart backgroundColor={'red'} maxValue={40} data={barData} />

The output becomes-

maxValue

Notice the padding at the top is now gone!

How it works-

If we don't provide the maxValue, it computes the maxValue as follows-
It takes the biggest value in the data array and the next reading on the y axis becomes the maxValue.
For example, in the above case, the biggest value in the data array is 40 so the next reading on y axis, i.e. 50 becomes the maxValue.

from react-native-gifted-charts.

Abhinandan-Kushwaha avatar Abhinandan-Kushwaha commented on June 1, 2024

Regarding your second question @verofy-simon-denny, you can wrap the <BarChart/> component in a <View/> and give the View some negative margin to the left.

Although it's a workaround, but for now this is the best way, and doesn't break anything as long as as we have hidden the y axis labels using the hideYAxisText prop

from react-native-gifted-charts.

verofy-simon-denny avatar verofy-simon-denny commented on June 1, 2024

Thank you for the answers, appreciate the time and the great library.

It makes sense, but I can't seem to set the height and max value at the same time, am I doing something wrong here?

I've used your example, but added height:

<BarChart backgroundColor={'red'} maxValue={40} data={barData} height={140} />

Screenshot 2022-01-21 at 17 43 54

Many Thanks, Simon.

from react-native-gifted-charts.

Abhinandan-Kushwaha avatar Abhinandan-Kushwaha commented on June 1, 2024

Yes @verofy-simon-denny, Even I faced the same issue. But the fact is there's no issue as such. I reloaded the app and it worked like a charmπŸ’«βœ¨

Please try reloading the app after changing any of these props- maxValue, stepValue, stepHeight, height
If it's not solved even after reloading, please do let me know, I will work on it.

from react-native-gifted-charts.

Hanuman-Ghawade avatar Hanuman-Ghawade commented on June 1, 2024

Thank you for the answers, appreciate the time and the great library.

It makes sense, but I can't seem to set the height and max value at the same time, am I doing something wrong here?

I've used your example, but added height:

<BarChart backgroundColor={'red'} maxValue={40} data={barData} height={140} />

Screenshot 2022-01-21 at 17 43 54

Many Thanks, Simon.

Hi @verofy-simon-denny ,

I am facing the same issue. But it only happens when I use the topLabelComponent. Otherwise, it is working fine.

Please suggest any answer.

Thanks in advance.

from react-native-gifted-charts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.