From: declerambaul Date: Mon, 2 Jul 2012 13:49:28 +0000 (+0200) Subject: SVG rerenders each time the model changes and ChartType.renderChart() is called. X-Git-Url: http://git.less.ly:3516/?a=commitdiff_plain;h=7369c46733198b00527a3542eff3a11f77a5b5f6;p=limn.git SVG rerenders each time the model changes and ChartType.renderChart() is called. --- 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