From 7369c46733198b00527a3542eff3a11f77a5b5f6 Mon Sep 17 00:00:00 2001 From: declerambaul Date: Mon, 2 Jul 2012 15:49:28 +0200 Subject: [PATCH] SVG rerenders each time the model changes and ChartType.renderChart() is called. --- lib/chart/type/d3-chart.co | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/chart/type/d3-chart.co b/lib/chart/type/d3-chart.co index d9ba175..3e968d6 100644 --- a/lib/chart/type/d3-chart.co +++ b/lib/chart/type/d3-chart.co @@ -74,10 +74,13 @@ class exports.D3ChartType extends ChartType .domain d3.extent allValues .range [ height - margin.top - margin.bottom, 0 ] + + # Hack. Remove svg if it exists. If @model changes, the graph will be redrawn + svg = d3.select viewport.0 .selectAll "svg" + .remove() # Select the svg element, if it exists. svg = d3.select viewport.0 .selectAll "svg" .data [cols] - # ...Otherwise, create the skeletal chart. enterFrame = svg.enter() .append "svg" .append "g" @@ -121,7 +124,7 @@ class exports.D3ChartType extends ChartType # FOR NOW take line as default chartElement ?= 'd3-line' # @model.get "chartElement" # create d3 chart element and render it - chEl = D3ChartElement.create chartElement + chEl = D3ChartElement.create chartElement chEl.renderChartElement d, frame ,xScale, yScale -- 1.7.0.4