Box not aligning correctly on bar chart
See original GitHub issueHi, 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.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:9 (3 by maintainers)
Top 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 >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
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.
@Techn1x Thanks, Hope it helped solve your problem!