question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Help] xAxis values not aligned with BarChart

See original GitHub issue

What is the problem?

xAxis doesn’t render the values inline with BarChart

screen shot 2018-06-28 at 11 04 13 pm

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:open
  • Created 5 years ago
  • Reactions:2
  • Comments:28 (8 by maintainers)

github_iconTop GitHub Comments

9reactions
marciogurkacommented, Oct 18, 2018

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! 😃

6reactions
alburdette619commented, Jul 30, 2018

The solution is not installing d3-scale as a dependency as @JesperLekland says. It entirely fixed the issue for me.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found