[Help] xAxis values not aligned with BarChart
See original GitHub issueWhat is the problem?
xAxis doesn’t render the values inline with BarChart
When does it happen?
just trying to render it onLoad using the following code
xAxis
<XAxis
scale={scale.scaleBand}
data={data}
xAccessor={({ item }) => item.title}
formatLabel={value => value}
svg={{
fill: 'grey',
fontSize: 10,
}}
/>
What platform?
- [x ] iOS 11
React Native version: 0.55.4
Code to reproduce
<View style={{ padding: 10 }}>
<View style={{ flexDirection: 'row', height: 150 }}>
<YAxis
data={data}
yAccessor={({ item }) => item.value}
formatLabel={value => value}
numberOfTicks={5}
min={0}
svg={{
fill: 'grey',
fontSize: 10,
}}
/>
<BarChart
style={{ flex: 1, marginLeft: 5 }}
data={data}
scale={scale.scaleBand}
yAccessor={({ item }) => item.value}
gridMin={0}
svg={{
fill: '#A6B4F3',
}}
>
<Grid />
</BarChart>
</View>
<XAxis
scale={scale.scaleBand}
data={data}
xAccessor={({ item }) => item.title}
formatLabel={value => value}
svg={{
fill: 'grey',
fontSize: 10,
}}
/>
</View>
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:28 (8 by maintainers)
Top Results From Across the Web
BarChartView: xAxis values are not aligned with bars ... - GitHub
I migrated my diagrams to Charts 3.0.1. It worked quite smoothly, but I cannot manage to align the bar charts to my xAxis...
Read more >MPandroid x axis labels not aligning with bar chart
I've tried that. What happens is that they do align, but the first label completely disappears off the screen and all label positions...
Read more >Horizontal barchart with axis table, Labels won't align
I'm trying to create a horizontal barchart with a label above the y-axis values (left aligned) and also a label above the bars...
Read more >FCC: D3 Bar Chart X-Axis not aligned with data - JavaScript
The problem is your x-axis is a linear scale (plain numbers) when the data is time (years, quarters). The tests for the bar...
Read more >Xaxis chart labels not aligning with bars in Highcharts
Hi psivadasan, Thanks for contacting us with your question. Most likely you need to disable grouping option, which is enabled by default for...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I had the same issue, then checked that the “correct” d3-scale lib is inside the react-native-svg-charts folder inside node_modules, like this: node_modules/react-native-svg-charts/node_modules/d3-scale, when I imported this lib with this path all worked fine! 😃
The solution is not installing d3-scale as a dependency as @JesperLekland says. It entirely fixed the issue for me.