Synchronizing background color changes and data updates in a dynamically updating dygraph

162 views
Skip to first unread message

Mike Schaeffer

unread,
Feb 18, 2014, 9:57:42 PM2/18/14
to dygraph...@googlegroups.com
I'm currently building a dashboard style web page that uses Dygraph to display several continually updating strip charts. To make it more obvious when the data behind a strip chart has gone stale, I'm using an underlayCallback to dim the background of the chart if the data hasn't updated after a timeout period has elapsed.  If the data resumes updating, I update the chart with the new data and restore the background to full brightness to indicate that the data is no longer stale.

My current implementation of this feature is done with a single call to updateOptions that controls both the underlayCallback and the data being displayed by the chart.  Once I make the call to updateOptions, I see both the background color change and the data update.  However, the background color change happens a second or two before the data updates. During this window, the graph is displaying stale data with a background color that indicates that the data is not stale.

Is there any way to synchoronize the background color change with the data update?  The duration of the delay appears to be related to the length of the data set being displayed by the dygraph.  I'm assuming that Dygraph is internally processing the data prior to its being actually displayed. The only thing I can think of at this point is that there might be a way, if I call updateOptions, with block_redraw set, and then force a redraw when Dygraph is actually ready to render. But I'm not sure if that's even workable, much less ideal.

Something else I should mention is that I've also tried using CSS to control the background color of stale charts.  That approach works, but (predictably) suffers from the same sort of synchronization issues. The background color change is faster than the data update.

Thanks for any suggestions you might have.

-Mike

Mike Schaeffer

unread,
Feb 19, 2014, 2:21:08 PM2/19/14
to dygraph...@googlegroups.com

After sitting on the problem for a while, and revisiting my code, this is not an issue with dygraph.

Without getting into too many details, I was using the wrong property name in a call to updateOptions. After correcting the property name, the behavior is synchronized, as you'd expect.

Thanks,
Mike

Dan Vanderkam

unread,
Feb 19, 2014, 4:49:27 PM2/19/14
to dygraphs-users

Yeah, this should really be an error.

--
You received this message because you are subscribed to the Google Groups "dygraphs-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dygraphs-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Reply all
Reply to author
Forward
0 new messages