Class: MotionPlot::BarDelegate
- Inherits:
-
Object
- Object
- MotionPlot::BarDelegate
- Defined in:
- lib/motion-plot/chart/delegates/bar_delegate.rb
Instance Method Summary collapse
- #barPlot(plot, barWasSelectedAtRecordIndex: index) ⇒ Object
-
#initialize(source) ⇒ BarDelegate
constructor
delegate :series, :to => :delegated_to.
- #numberForPlot(plot, field: field_enum, recordIndex: index) ⇒ Object
- #numberOfRecordsForPlot(plot) ⇒ Object
Constructor Details
#initialize(source) ⇒ BarDelegate
delegate :series, :to => :delegated_to
6 7 8 |
# File 'lib/motion-plot/chart/delegates/bar_delegate.rb', line 6 def initialize(source) @delegated_to = source end |
Instance Method Details
#barPlot(plot, barWasSelectedAtRecordIndex: index) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/motion-plot/chart/delegates/bar_delegate.rb', line 20 def (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.), y_value], plotSpace: @delegated_to.graph.defaultPlotSpace)) end |
#numberForPlot(plot, field: field_enum, recordIndex: index) ⇒ Object
14 15 16 17 18 |
# File 'lib/motion-plot/chart/delegates/bar_delegate.rb', line 14 def numberForPlot(plot, field:field_enum, recordIndex:index) data = @delegated_to.series[plot.identifier].data (field_enum == CPTBarPlotFieldBarTip) ? data[index] : index end |
#numberOfRecordsForPlot(plot) ⇒ Object
10 11 12 |
# File 'lib/motion-plot/chart/delegates/bar_delegate.rb', line 10 def numberOfRecordsForPlot(plot) @delegated_to.series[plot.identifier].data.size end |