From a83eb21d058091e75d5a3d247220d31086b2655c Mon Sep 17 00:00:00 2001 From: Helene Moorman Date: Sat, 21 Feb 2015 23:27:19 -0800 Subject: [PATCH] added graph.resample method to prevent browser crash from trying to plot too many points --- kiln/static/js/temp_graph.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/kiln/static/js/temp_graph.js b/kiln/static/js/temp_graph.js index 20a792b..75ea343 100644 --- a/kiln/static/js/temp_graph.js +++ b/kiln/static/js/temp_graph.js @@ -150,7 +150,33 @@ var tempgraph = (function(module) { this.y.domain(extent); this.draw(); } + module.Graph.prototype.resample = function(data) { + var npoints = 1000; + var idxs = [] + for (var i=0;i=this.xlim()[0] && data[i].x<=this.xlim()[1]) { + within.push(data[i]); + within_idx.push(idxs[i]); + } + } + if (within.length>npoints) { + md = Math.floor(within.length/npoints); + var fin = [] + for (var i=0; i