Class: MotionPlot::Bar
Constant Summary collapse
- CPDBarInitialX =
0.0
Instance Attribute Summary collapse
-
#data_hash ⇒ Object
readonly
Returns the value of attribute data_hash.
Attributes inherited from Base
#axes, #data_label, #graph, #layer_hosting_view, #legend, #major_grid_line_style, #plot_options, #plot_space, #plots, #series, #theme, #title, #xaxis, #yaxis
Instance Method Summary collapse
Methods inherited from Base
#add_axis_title, #add_chart_title, #add_legend, #add_plot_space, #add_plot_symbol, #add_xy_range, #bootstrap, #default_padding, #initWithOptions
Instance Attribute Details
#data_hash ⇒ Object (readonly)
Returns the value of attribute data_hash.
4 5 6 |
# File 'lib/motion-plot/chart/bar_plot.rb', line 4 def data_hash @data_hash end |
Instance Method Details
#add_series ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/motion-plot/chart/bar_plot.rb', line 8 def add_series @stacking = @plot_options ? @plot_options.[:stacking] : nil = CPDBarInitialX @data_hash = {} = (@plot_options and @plot_options.[:orientation] == "vertical") ? true : false @delegate_object = case @stacking when "normal" StackBarDelegate.new(self) when "percent" PercentBarDelegate.new(self) when "waterfall" WaterfallDelegate.new(self) else BarDelegate.new(self) end @series.keys.each_with_index do |name, index| = CPTBarPlot.tubularBarPlotWithColor(@series[name].color, horizontalBars: ) . = CPTDecimalFromDouble(@series[name].width) . = CPTDecimalFromDouble() unless(@stacking) .identifier = name _style = CPTMutableLineStyle.alloc.init _style.lineWidth = 0.5 _style.lineColor = CPTColor.lightGrayColor .lineStyle = _style .dataSource = @delegate_object .delegate = @delegate_object . = @stacking ? true : false @graph.addPlot() @plots << animate() += @series[name].width @data_hash[index] = @series[name].data end end |
#animate(bar) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/motion-plot/chart/bar_plot.rb', line 51 def animate() .anchorPoint = [0.0, 0.0] scale_direction = (@plot_options and @plot_options.[:orientation] == "vertical") ? "transform.scale.x" : "transform.scale.y" scaling = CABasicAnimation.animationWithKeyPath(scale_direction) scaling.fromValue = 0.0 scaling.toValue = 1.0 scaling.duration = 1.0 scaling.removedOnCompletion = false scaling.fillMode = KCAFillModeBackwards .addAnimation(scaling, forKey:"scaling") end |