Class: MotionPlot::BarDelegate

Inherits:
BaseDelegate show all
Defined in:
lib/motion-plot/chart/delegates/bar_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

#barPlot(plot, barWasSelectedAtRecordIndex: index) ⇒ Object



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

def barPlot(plot, barWasSelectedAtRecordIndex: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+CPTDecimalFloatValue(plot.barOffset), y_value], plotSpace: @delegated_to.graph.defaultPlotSpace))
end

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



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

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

  (field_enum == CPTBarPlotFieldBarTip) ? data[index] : index
end