Comments (4)
Hi @fleuverouge Can you share the Code here?
from react-native-gifted-charts.
from react-native-gifted-charts.
Hi @Abhinandan-Kushwaha ,
Thanks for replying
I had trouble with making a bar's label displayed fully with center-x alignment in small screens (like in the picture), so for each bar, I created 2 "mock" bars.
Here's my code:
Sizes calculation:
const barWidth = width * 0.1;
const labelWidth = width * 0.18;
const mockBarWidth = (labelWidth - barWidth) / 2;
adjustedData: ( calculating this is a complicated process from our raw data, so I just pasted the output here)
[
{
"value":3,
"spacing":0,
"label":"Physics",
"labelWidth":87,
"frontColor":"rgba(0,0,0,0)",
"barWidth":26.099999999999998,
"labelTextStyle":{
"color":"black",
"fontSize":12
}
},
{
"value":3,
"frontColor":"green",
"spacing":0,
"barWidth":34.800000000000004
},
{
"value":3,
"barWidth":26.099999999999998,
"frontColor":"rgba(0,0,0,0)",
"spacing":3.48
},
{
"value":6,
"spacing":0,
"label":"Mathematics",
"labelWidth":87,
"frontColor":"rgba(0,0,0,0)",
"barWidth":26.099999999999998,
"labelTextStyle":{
"color":"black",
"fontSize":12
}
},
{
"value":6,
"frontColor":"black",
"spacing":0,
"barWidth":34.800000000000004
},
{
"value":6,
"barWidth":26.099999999999998,
"frontColor":"rgba(0,0,0,0)",
"spacing":3.48
}
]
<BarChart
backgroundColor={colors.white}
height={chartHeight}
noOfSections={3}
barBorderRadius={0}
data={adjustedData}
isAnimated
disablePress
/>
from react-native-gifted-charts.
Hi @fleuverouge
You can solve this issue by using the maxValue
and stepValue
props.
Try passing maxValue = {9}
Detailed inspection of the issue -
- Since the data includes values 3 and 6, it sets the maxValue = 10 (multiple of 10 next to the biggest value).
- And then since, you have passed noOfSections = 3 , each section height becomes 3.333....
- And, the labels appearing on y-axis are rounded figures, so the 3 that you see on y-axis is not actually 3, instead it's a rounded value of 3.333... (You can disable rounding by using the
showFractionalValues
prop.)
Note -
Whenever we use the noOfSections
we must passstepValue
and maxValue
also.
It's mentioned in the documents here-
BarChartProps.md
Hope it solves your issue. Cheers! 🎉
from react-native-gifted-charts.
Related Issues (20)
- Add support to control the backgroundColor of each section of the yAxis individually HOT 1
- Does gifted charts support zoom implementation? HOT 1
- BarChart secondaryData is completely ignored
- [BUG] LineChart not displaying dataPointLabelComponent and dataPointText properly on RTL Layouts.
- Having trouble with pointerConfig - scrolling over data HOT 3
- secondary line data not aligning with secondary y axis HOT 2
- When I run in Android device that i am getting this issue HOT 4
- How do we add border radius to semi circle pie charts? HOT 5
- Animate piechart/semi circle HOT 2
- innerCircleBorderWidth not being applied
- Line chart - Multiple lines
- Line chart spacing
- RulesType at LineChart does not work HOT 1
- [BUG]:You specified `onScroll` on a <ScrollView> but not `scrollEventThrottle`. You will only receive one event
- How to achieve Multiple Circular Progressbar using this library? HOT 3
- PieChart focusOnPress stops working when onPress prop is provided HOT 1
- dynamic timestamp for xaxis
- date-time xaxis for react native HOT 1
- Pointer Config and Pointer Label component is not responsive in line graph. HOT 1
- first and last xAxisLabel are cut-off
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.