From 48a8dc09896aa18c657241f6955376bd3a590bdc Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Mon, 5 Jun 2017 16:07:21 +0100 Subject: [PATCH] Redraw grid properly if gridSize changes --- editor/js/ui/view.js | 48 +++++++++----------------------------------- 1 file changed, 10 insertions(+), 38 deletions(-) diff --git a/editor/js/ui/view.js b/editor/js/ui/view.js index 9ceaf8d1d..852a145eb 100644 --- a/editor/js/ui/view.js +++ b/editor/js/ui/view.js @@ -206,67 +206,39 @@ RED.view = (function() { .attr("height", space_height) .attr("fill","#fff"); - var gridScale = d3.scale.linear().range([0,space_width]).domain([0,space_width]); var grid = vis.append("g"); - - grid.selectAll("line.horizontal").data(gridScale.ticks(space_width/gridSize)).enter() - .append("line") - .attr( - { - "class":"horizontal", - "x1" : 0, - "x2" : space_width, - "y1" : function(d){ return gridScale(d);}, - "y2" : function(d){ return gridScale(d);}, - "fill" : "none", - "shape-rendering" : "crispEdges", - "stroke" : "#eee", - "stroke-width" : "1px" - }); - grid.selectAll("line.vertical").data(gridScale.ticks(space_width/gridSize)).enter() - .append("line") - .attr( - { - "class":"vertical", - "y1" : 0, - "y2" : space_width, - "x1" : function(d){ return gridScale(d);}, - "x2" : function(d){ return gridScale(d);}, - "fill" : "none", - "shape-rendering" : "crispEdges", - "stroke" : "#eee", - "stroke-width" : "1px" - }); - grid.style("visibility","hidden"); - updateGrid(); function updateGrid() { + var gridTicks = []; + for (var i=0;i