Comments (7)
Thanks that works now.
from react-native-gifted-charts.
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.
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-
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-
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.
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.
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} />
Many Thanks, Simon.
from react-native-gifted-charts.
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.
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} />
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)
- LineChart Crash when data.length is 1, everything fine when data is not available or more than 1 HOT 1
- not smooth line in linechart HOT 1
- Question: How to prevent data point label from overflowing? HOT 1
- Super simple fix for LineChart data. Please fix asap. itll take seconds! HOT 3
- Error : UIView base class does not support pointerEvent value: box-none [Ask for help] HOT 12
- How do I show label on referenceLine of BarChart HOT 4
- X Labels not showing on Android HOT 3
- Pressable's onPress wont trigger near BarChart HOT 1
- Feature request: Icons inside BarChart and PieChart HOT 11
- Dynamic Y axis labels HOT 1
- App Crashed after build Apk HOT 5
- onLongPress prop [Feature Request] HOT 3
- Error: Unable to resolve module gifted-charts-core HOT 4
- Unable to resolve module 'gifted-charts-core' HOT 6
- BarChart: stepValue behaves unexpected HOT 4
- How to change the color of the bar based on click event HOT 3
- Solution for crashing version HOT 1
- BarChart animation canceled after data change HOT 5
- How I can create Scatter Chart HOT 2
- topLabelComponent not show HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-gifted-charts.