examples/scatterplot/scatterplot.rb
#--------------------------------------------------------------------------------------
# This method updates and plots all the points in the scatter plot. Note that we use
# transition, duration and each methods to animate the update process.
#
# @param x_scale [LinearScale] the x scale for the updated dataset. Uses @x_scale as
# default since x_scale is used inside a block.  @x_scale should have already being
# updated
# @param y_scale [LinearScale] the y scale for the updated dataset. Uses @y_scale as
# default since y_scale is used inside a block.  @y_scale should have already being
# updated
#--------------------------------------------------------------------------------------
This method updates and plots all the points in the scatter plot. Note that we use
transition, duration and each methods to animate the update process.
This method updates and plots all the points in the scatter plot . Note that we use transition duration and each methods to animate the update process .
def update_points(x_scale = @x_scale, y_scale = @y_scale)
    @svg.selectAll("circle")
      .data(@dataset)
      .transition(nil)
      .duration(2000)
      .each("start") { $d3.select(@this)
                         .attr("fill", "magenta")
                         .attr("r", 3) }
      .attr("cx") { |d, i| x_scale[d[0]] }
      .attr("cy") { |d, i| y_scale[d[1]] }
      .each("end") { $d3.select(@this)
                       .transition(nil)
                       .duration(1000)
                       .attr("fill", "black")
                       .attr("r", 2) }
  end
def update_points ( x_scale = @x_scale , y_scale = @y_scale ) @svg . selectAll ( "circle" ) . data ( @dataset ) . transition ( nil ) . duration ( 2000 ) . each ( "start" ) { $d3 . select ( @this ) . attr ( "fill" , "magenta" ) . attr ( "r" , 3 ) } . attr ( "cx" ) { | d , i | x_scale [ d [ 0 ] ] } . attr ( "cy" ) { | d , i | y_scale [ d [ 1 ] ] } . each ( "end" ) { $d3 . select ( @this ) . transition ( nil ) . duration ( 1000 ) . attr ( "fill" , "black" ) . attr ( "r" , 2 ) } end
This method updates and plots all the points in the scatter plot.
This method updates and plots all the points in the scatter plot .
x_scale
the x scale for the updated dataset. Uses @x_scale as default since x_scale is used inside a block. @x_scale should have already being updated
the x scale for the updated dataset . Uses @x_scale as default since x_scale is used inside a block . @x_scale should have already being updated
y_scale
the y scale for the updated dataset. Uses @y_scale as default since y_scale is used inside a block. @y_scale should have already being updated
the y scale for the updated dataset . Uses @y_scale as default since y_scale is used inside a block . @y_scale should have already being updated