Class: MotionPlot::LineDelegate

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

Instance Method Summary collapse

Methods inherited from BaseDelegate

#initialize, #numberOfRecordsForPlot

Constructor Details

This class inherits a constructor from MotionPlot::BaseDelegate

Instance Method Details

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



19
20
21
22
23
# File 'lib/motion-plot/chart/delegates/line_delegate.rb', line 19

def numberForPlot(plot, field:field_enum, recordIndex:index)
  data  = @delegated_to.series[plot.identifier].data

  (field_enum == CPTScatterPlotFieldY) ? data[index] : index
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.



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

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

#scatterPlot(plot, plotSymbolWasSelectedAtRecordIndex: index) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/motion-plot/chart/delegates/line_delegate.rb', line 9

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