Dygraphs Dynamics Points Limit

45 views
Skip to first unread message

James Reynolds

unread,
May 29, 2015, 2:32:02 PM5/29/15
to dygraph...@googlegroups.com
I've been using dygraphs for some time now dealing with sensor data tracking. Over the past couple of months, the data to plot in one graph has risen to millions of points. Browser performance was really starting to suffer. The issue was trying to draw too many objects on the canvas. The available solutions weren't appealing. Josh Sanderson's dynamic loading, which was the closest to being what I needed, didn't work in my situation (reconfiguring the server backend was not an option). My solution was to modify the _drawPointsOnLine function. In my case, I wasn't drawing any lines, so I was only concerned about the points. By deleting the idx++ in the for loop condition (around line 1371) and adding at the end of the for loop

if (pointsOnLine.length > 1000000){
idx = idx + 100;
} else if (pointsOnLine.length > 100000){
idx = idx + 50;
} else if (pointsOnLine.length > 10000){
idx = idx + 10;
} else{
idx++;
}

The end result is that you skip drawing points when you have more of them in the draw window. It isn't that dygraphs can't handle large amounts—it will eventually draw all of them. However, when you have end users who don't understand the process and you have to zoom in on the graph, this really helps performance.
Reply all
Reply to author
Forward
0 new messages