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.

Box not aligning correctly on bar chart

See original GitHub issue

Hi, I have added two box annotations however they are not working to how I expect them to be. Below is my code:

           annotation: {
              annotations: [{
                type: 'box',
                id: 'hLine',
                xScaleID: 'x-axis-0',
                yScaleID: 'y-axis-0',
                xMin: "005",
                xMax: "006",
                yMax: 50000,
                yMin: 50000,
                borderColor: 'red',
                borderWidth: 5,
                backgroundColor: 'green'
              },
              {
                type: 'box',
                xScaleID: 'x-axis-0',
                yScaleID: 'y-axis-0',
                xMin: "006",
                xMax: "006",
                yMax: 60000,
                yMin: 60000,
                borderColor: 'red',
                borderWidth: 5,
                backgroundColor: 'green'
              }]
            } 

See Attached image.

Firstly the xMin is starting from the middle of ‘005’ and ending in the middle of ‘006’. I also tried putting the xMin and xMax as the same ID however it disappears.

capture

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
TBVanderley4545commented, Oct 12, 2018

Best solution I had was to create a secondary x axis then set its display to false so that the labels wouldn’t show at the bottom of the chart. I had 5 bars that I needed in my chart, so I made my second x-axis have the labels [1, 2, 3, 4, 5, 6] (don’t use string values, just used ints in mine). I charted all of my data to have xAxisID as the primary-x. For the box annotations, I used xScaledID: “secondary-x” (or whatever you name your secondary x-axis). I then gave

box 1: xMin: 1 xMax: 2

box 2: xMin: 2 xMax: 3

box 3: xMin: 3 xMax: 4

box 4: xMin: 4 xMax: 5

box 5: xMin: 5 xMax: 6

I know this is a super late answer, but hopefully it helps someone else. If you need more clarification in my answer, just respond to me, and I can try to help more.

1reaction
TBVanderley4545commented, Jan 22, 2019

@Techn1x Thanks, Hope it helped solve your problem!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Column alignment on chart is wrong - MSDN - Microsoft
In your chart, the series group has more than one instance, and that is why the bars not align as you expect. Besides,...
Read more >
Help with Bar-Line Chart..not aligned?? - Google Groups
Hi All,. I am trying to plot a line chart over a column chart (4 categories). The columns on the primary y-axis, while...
Read more >
Dual Axis Bar is not Aligned to Line - Tableau Community
I have a combination graph where the dual-axis bars (eg. January 2017) are not aligned to the line data (January 2017).
Read more >
Lining up related column graphs at the horizontal axis
Creating the graph · Remove the gridlines · Remove the vertical axis since the values there are not the values we want to...
Read more >
D3 bar graph X-ticks not aligning - Stack Overflow
Your labels array has 13 items but your data array has only 12. Make the lengths equal and your ticks will line up....
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