Performance difference between recreating the graph and updating the data

51 views
Skip to first unread message

Clemens Blank

unread,
Jun 3, 2015, 11:29:44 AM6/3/15
to dygraph...@googlegroups.com
Hello dygraphs community,

I wonder if there is a big difference in performance between recreating a graph and updating the data - for the simple reason if it is worth the effort to check if the graph already exists or not.

I have a multipage html file, so all pages (with dygraphs) are loaded, and I wonder what to do when I switch pages. Right now I check if the graph is already created, and only create it if not. This seemed cleaner than to recreate it every time the user switches pages, but I could not see (visibly) a real performance difference, so I wonder if this is really worth the effort - maybe recreating isn't that much of a difference compared to update the "file" data?

Best regards

Clemens

Dan Vanderkam

unread,
Jun 3, 2015, 1:32:12 PM6/3/15
to dygraph...@googlegroups.com
There's almost no overhead to creating a new chart vs updating the data in an existing one. You should do whatever results in cleaner code on your end.
--
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/d/optout.

Clemens Blank

unread,
Jun 3, 2015, 7:15:00 PM6/3/15
to dygraph...@googlegroups.com
Thank you, that's good to know - it would be just another possible source of errors, so I'll stick with recreating then (I had some strange happenings randomly, like graphs only drawn after a window resize - not sure if it was really related to dygraphs, but recreating the graph always fixes this automatically).

Clemens Blank

unread,
Jun 21, 2015, 2:11:43 PM6/21/15
to dygraph...@googlegroups.com
I'm not so sure about this anymore - I just switched my update routine to create a new graph instead of updating and the responsiveness is reduced by a lot. 

For background information: I'm updating around 15 graphs, each containing around 500 points - according to slider values the user can set, anytime the slider changes, new data will be calculated and all graphs updated with new points.

One might think the server response time and calculation time is the limiting factor, and although this set's a limit (I won't reach smooth 60fps haha), switching to create new graphs on every slider event is a huge difference in user experience.

Just added this for information - maybe I'm doing something wrong, but afaik I only switched the last part in the code - updating vs creating (there is still the possibility my create_graphs function code is slower, but I don't see it right now).

Best regards

Clemens


Am Mittwoch, 3. Juni 2015 19:32:12 UTC+2 schrieb danvk:

Clemens Blank

unread,
Jun 21, 2015, 2:57:26 PM6/21/15
to dygraph...@googlegroups.com
I just created a jsFiddle to give a rough comparison, and it also shows that creating the graphs is always slower - although, especially on low values for count, the results differ a lot, while at high values (1000 times or so), it's a factor 4 for my mostly:

http://jsfiddle.net/7hmcL51w/

Of course, this is an unrealistic scenario, but I guess it's safe to say that updating is always the faster way, by a noticeable amount. On the other hand, I don't know anything about javascript, so I might miss out something.
Reply all
Reply to author
Forward
0 new messages