examples/scatterplot/scatterplot.rb
def update(dataset)

    @dataset = dataset

    # correct the x and y scale to the new dataset
    x_min, x_max = @dataset.minmax_by { |d| d[0] }
    y_min, y_max = @dataset.minmax_by { |d| d[1] }

    # fix the scale to the new dataset
    @x_scale.update([0, x_max[0]], [@padding, @width - @padding * 2])
    @y_scale.update([0, y_max[1]], [@height - @padding, @padding])

    # update the points, axes and labels
    update_points
    @axes.update(@x_scale.scale, @y_scale.scale)
    update_labels
    
  end
#--------------------------------------------------------------------------------------
# This method is called when the dataset is updated.  This will trigger the update of
# points, labels and axes
#
# @param dataset [Array] a new dataset with the same number of elements as the previous
# dataset
#--------------------------------------------------------------------------------------
This method is called when the dataset is updated.  This will trigger the update of
points, labels and axes
This method is called when the dataset is updated . This will trigger the update of points labels and axes
def update(dataset)
    @dataset = dataset
    x_min, x_max = @dataset.minmax_by { |d| d[0] }
    y_min, y_max = @dataset.minmax_by { |d| d[1] }
    @x_scale.update([0, x_max[0]], [@padding, @width - @padding * 2])
    @y_scale.update([0, y_max[1]], [@height - @padding, @padding])
    update_points
    @axes.update(@x_scale.scale, @y_scale.scale)
    update_labels
  end
def update ( dataset ) @dataset = dataset x_min , x_max = @dataset . minmax_by { | d | d [ 0 ] } y_min , y_max = @dataset . minmax_by { | d | d [ 1 ] } @x_scale . update ( [ 0 , x_max [ 0 ] ] , [ @padding , @width - @padding * 2 ] ) @y_scale . update ( [ 0 , y_max [ 1 ] ] , [ @height - @padding , @padding ] ) update_points @axes . update ( @x_scale . scale , @y_scale . scale ) update_labels end
This method is called when the dataset is updated.
This method is called when the dataset is updated .
# correct the x and y scale to the new dataset # fix the scale to the new dataset # update the points, axes and labels
dataset
a new dataset with the same number of elements as the previous dataset
a new dataset with the same number of elements as the previous dataset