Black Lives Matter. Please consider donating to Black Girls Code today.
Learn how to use COVID-19 data in open source Dash apps. Register for the Sept 23rd webinar with IQT!

X axis (of type Date) showing weird values with just one datapoint provided

Not sure if it’s a bug, or I’m missing something.


That is the desired (unfortunate) behaviour. 1-category bar traces get a width of 1 which in date coordinates mean 1 millisecond as picture above.

This is far from ideal. But, finding the correct default isn’t obvious either.

thank you for reply.

is there any workaround? tried layout.xaxis.tickvals, but couldn’t fix.

what are you trying to do?

set tickvals to an array that matches x array (eg, [“2016-07-09”])

Here’s how:

1 Like

brilliant! thank you!!!

another solution that worked for me - set xaxis type to “category”:

Do you know how this would work for python?


1 Like

My problem is a little more confusing actually. I was wondering if you could help. Basically, I am overlapping a scatter plot and a bar graph (x axis are date values). Strangely enough, the size of the bar isn’t based only on the range of the x axis. When I have only one bar value, depending on the x axis range, it will either be very thin or just not visible (exists if you zoom 5+ times). As the number of bars get larger, the width of the bars also get larger until there are too many bars and it gets smaller again. I guess I simply don’t understand why the single bars are so tiny and how adding another bar to the same data set makes the width of both much larger.

1 Like

Examples of what I am talking about if it helps.