Date axis zooming behavior


#1

Hello all,

My goal is the following. If have different plots, and some of them are showing data per day. For these types of plots time is not relevant. However when you zoom in, at some point, the time is shown where the data is always shown at 00:00:00. This can be confusing for a user when the data represents an event on that day and not on 00:00:00.

Categorical axis is not an option, because I would like to keep the a linear time axis, and not every day there is data.

Options I thought about:

  • have a maximum zoom
  • have control over the datetime axis formatting, something with dtick?
  • choose a type of calender like gregorian, which does not include time or something

Thus my question is, do you (reader) know any way such that I could achieve my goal?

Regards,
Frank


#2

You might want to look at https://plot.ly/javascript/reference/#layout-xaxis-tickformatstops

Yes, we’re planning on adding this https://github.com/plotly/plotly.js/issues/1876

I’'m not sure what you mean here. The gregorian is the default calendar for all date axes.


#3

Thx again Etienne,

https://plot.ly/javascript/reference/#layout-xaxis-tickformatstops

in combination with

https://github.com/plotly/plotly.js/issues/1946

really helped. However I still do not completely get my desired behavior. I used

        'tickformatstops': [
            {
                'enabled':'true',
                'dtickrange': [0, 86400000.0],
                'value': '%b %d'
            }
        ]

If I now zoom in I get:

I do would like to keep the changes on dateformating when zooming out, thus manually set the date ticks with dtick didn’t work.

Also tried to do this:

        'tickformatstops': [
            {
                'enabled':'true',
                'dtickrange': [0, 86400000.0],
                'value': ''
            }
        ]

Rather have no ticks than repetitive ticks as in the image, but when value set to ‘’, the tickformatstop is simply ignored.

Could you hint me in the right direction?

Regards,
Frank