Class: MotionPlot::BeizerCurveDelegate

Inherits:
BaseDelegate show all
Defined in:
lib/motion-plot/chart/delegates/beizer_curve_delegate.rb

Instance Method Summary collapse

Methods inherited from BaseDelegate

#initialize

Constructor Details

This class inherits a constructor from MotionPlot::BaseDelegate

Instance Method Details

#numberForPlot(plot, field: field_enum, recordIndex: index) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/motion-plot/chart/delegates/beizer_curve_delegate.rb', line 25

def numberForPlot(plot, field:field_enum, recordIndex:index)

  case field_enum
  when CPTScatterPlotFieldY
    num = index
  when CPTScatterPlotFieldX
    p @delegated_to.series[plot.identifier].data

    num = @delegated_to.series[plot.identifier].data.call(index)
  end
  
  num
end

#numberOfRecordsForPlot(plot) ⇒ Object



4
5
6
7
8
# File 'lib/motion-plot/chart/delegates/beizer_curve_delegate.rb', line 4

def numberOfRecordsForPlot(plot)
  step_size = @delegated_to.plot_options.line[:step_size] || 1
  p @delegated_to.plot_options.line[:data_size] / step_size
  @delegated_to.plot_options.line[:data_size] / step_size
end

#plotSpace(space, willChangePlotRangeTo: new_range, forCoordinate: coordinate) ⇒ Object

This implementation of this method will put the line graph in a fix position so it won’t be scrollable.



11
12
13
# File 'lib/motion-plot/chart/delegates/beizer_curve_delegate.rb', line 11

def plotSpace(space, willChangePlotRangeTo:new_range, forCoordinate:coordinate)
  (coordinate == CPTCoordinateY) ? space.yRange : space.xRange
end

#scatterPlot(plot, plotSymbolWasSelectedAtRecordIndex: index) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/motion-plot/chart/delegates/beizer_curve_delegate.rb', line 15

def scatterPlot(plot, plotSymbolWasSelectedAtRecordIndex:index)
  if(@delegated_to.data_label and @delegated_to.data_label.annotation)
    @delegated_to.graph.plotAreaFrame.plotArea.removeAnnotation(@delegated_to.data_label.annotation)
    @delegated_to.data_label.annotation = nil
  end

  y_value = @delegated_to.series[plot.identifier].data[index].round(2)
  @delegated_to.graph.plotAreaFrame.plotArea.addAnnotation(@delegated_to.data_label.annotation_for(y_value, atCoordinate: [index, y_value], plotSpace: @delegated_to.graph.defaultPlotSpace))
end