Search code examples
javascriptjquerydygraphs

Dygraphs: Collapse/hide part of an x-axis date-range


I have a time-series (x-axis is Date format) which has consistent periods regularly empty, such as evenings and weekends. I am wondering whether it is possible to automatically collapse/hide a period of time on the x-axis in Dygraphs so that gaps do not appear in my plotted data? (e.g. the x-axis doesn't plot Saturday and Sundays, thus allowing Friday to run directly onto Monday).

Given that I doubt this functionality is available natively, does anyone have any suggestions on how to achieve this more manually?


Solution

  • As you surmised, there's no support direct for this sort of thing in dygraphs. This has been discussed on the mailing in the past.

    The gist is that the dygraphs x-axis is always continuous. You'll need to map your time dimension onto something that is continuous, e.g. "market open minutes". Then you'll have to update the tickers and axis/value formatters to reflect this.

    It's a fair bit of work but the necessary hooks do all exist. Please do share your solution if you go down this path!