From 222d523323d3eb043fa1fed90ab763ee04feae10 Mon Sep 17 00:00:00 2001 From: Maschell Date: Sat, 30 Dec 2017 23:41:37 +0100 Subject: [PATCH] Update graph while moving --- js/diagrams.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/js/diagrams.js b/js/diagrams.js index 7bef161..4755610 100644 --- a/js/diagrams.js +++ b/js/diagrams.js @@ -509,8 +509,7 @@ function createLineGraph(containerId, raceData){ var s = d3.event.selection || x2.range(); x.domain(s.map(x2.invert, x2)); - //Update the x axis data - focus.select(".axis--x").call(xAxis); + updateElements(); //Update the "preview" rectangle svg.select(".zoom").call(zoom.transform, d3.zoomIdentity @@ -524,6 +523,14 @@ function createLineGraph(containerId, raceData){ x.domain(t.rescaleX(x2).domain()); + updateElements(); + + //call the brush function + context.select(".brush").call(brush.move, x.range().map(t.invertX, t)); + } + + function updateElements(){ + //scale the path axis focus.selectAll(".pathLines").call(xAxis); @@ -534,9 +541,6 @@ function createLineGraph(containerId, raceData){ //Update x-axis focus.select(".axis--x").call(xAxis); - - //call the brush function - context.select(".brush").call(brush.move, x.range().map(t.invertX, t)); } }