Class: MotionPlot::StackBarDelegate
- Inherits:
-
BaseDelegate
- Object
- BaseDelegate
- MotionPlot::StackBarDelegate
- Defined in:
- lib/motion-plot/chart/delegates/stack_bar_delegate.rb
Instance Method Summary collapse
- #barPlot(plot, barWasSelectedAtRecordIndex: index) ⇒ Object
-
#numberForPlot(plot, field: field_enum, recordIndex: index) ⇒ Object
consign :series, :to => :delegated_to.
Methods inherited from BaseDelegate
#initialize, #numberOfRecordsForPlot
Constructor Details
This class inherits a constructor from MotionPlot::BaseDelegate
Instance Method Details
#barPlot(plot, barWasSelectedAtRecordIndex: index) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/motion-plot/chart/delegates/stack_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) plot_index = @delegated_to.series[plot.identifier].index y_pos = (0..plot_index).inject(0) {|base, i| base + @delegated_to.data_hash[i][index]} @delegated_to.graph.plotAreaFrame.plotArea.addAnnotation(@delegated_to.data_label.annotation_for(y_value, atCoordinate: [index+CPTDecimalFloatValue(plot.), y_pos], plotSpace: @delegated_to.graph.defaultPlotSpace)) end |
#numberForPlot(plot, field: field_enum, recordIndex: index) ⇒ Object
consign :series, :to => :delegated_to
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/motion-plot/chart/delegates/stack_bar_delegate.rb', line 6 def numberForPlot(plot, field:field_enum, recordIndex:index) case field_enum when CPTBarPlotFieldBarLocation index when CPTBarPlotFieldBarTip plot_index = @delegated_to.series[plot.identifier].index record_data = @delegated_to.series[plot.identifier].data[index] (plot_index, recordIndex:index, startValue:record_data) when CPTBarPlotFieldBarBase plot_index = @delegated_to.series[plot.identifier].index (plot_index, recordIndex:index) end end |