Hi, so I have a stack bar chart that has x-axis type as “date” and when I specify the date range in x-axis and disable the autorange, I get the first bar cut in half if it the same as the first or last range values
Hi @malzaeem welcome to the forum! When you ask for a specific
xaxis range, only this range is represented, but the bars have a finite width, therefore you only see the right half of the bar. If you want to display the whole bar, you can set yourself the width of bars using the
width attribute (be aware that for a date axis the width is in ms so in your example it’s a very large number of ms!), and you can specify the axis range to start at d - w/2 where d is the first date and w the width of the bar. I adapted your codepen in https://codepen.io/emmanuelle-plotly/pen/eYNdwRX : I set the width of bars to be (approximately) 6 days and I let the axis start 3 days before the first data of the
Thank you @Emmanuelle, your codepen link isn’t working. Also, I was hoping for a more general solution as in my case the date range and the number of bars are random (my codepen was a simplified version). So figuring the right width for the bars (as you did approximately as 6 days for the bar width) and sacrificing the correct start and end date to something different than what the user selected is too much (like subtracting days from the start date and adding days to the end date).
I think I’ll try different type chart like scatter or stacked lines since I noticed they don’t get cut in half if the first value is the same as the range start or end date
oops, link updated