Question

I've created the following dygraphs chart for stock data:

enter image description here

As you would expect, there is no market data present for weekend days (note that quotes are in UTC time). Dygraphs, however, insists on showing these days in the chart, which results in a [undesirable] straight line.

Is there any way to not show days that have no data in a dygraphs chart?

Was it helpful?

Solution

Drawing a discontinuous x-axis for financial charts is a difficult problem. dygraphs only supports continuous axes, so your only option is to make your axis continuous. Instead of having dates as your x-values, you'll need to have something continuous like "minutes that the market has been open since January 1". This will give you the plot that you want, but it will also give meaningless x-axis ticks and values in the legend when you hover. You'll have to write a custom x-axis ticker and valueFormatter (see dygraphs.com/options.html) to undo the mapping.

Does this sound like a lot of work? It is! That's one of the reasons dygraphs doesn't support it out of the box. If you do get something to work, please share it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top