Class: GoogleChart::BarChart
- Inherits:
-
Base
- Object
- Base
- GoogleChart::BarChart
- Includes:
- Axis, Color, DataArray, Fills, Grid, Legend, Markers
- Defined in:
- lib/google_chart/bar_chart.rb
Constant Summary
- ORIENTATIONS =
[:horizontal, :vertical]
- GROUPINGS =
[:grouped, :stacked]
Constants included from Markers
Markers::ORIENTATION, Markers::PRIORITY, Markers::SHAPES
Constants included from Axis
Axis::ALIGNMENT_MAPPING, Axis::AXIS_TYPE_MAPPING
Constants included from Fills
Fills::FILL_KINDS, Fills::FILL_TYPES, Fills::FILL_TYPES_SOLID, Fills::FILL_TYPE_CODES
Instance Attribute Summary (collapse)
-
- (Object) bar_spacing
Returns the value of attribute bar_spacing.
-
- (Object) bar_width
Returns the value of attribute bar_width.
-
- (Object) group_spacing
Returns the value of attribute group_spacing.
-
- (Object) grouping
Returns the value of attribute grouping.
-
- (Object) orientation
Returns the value of attribute orientation.
Attributes inherited from Base
#encoding, #height, #title, #title_color, #title_font_size, #width
Instance Method Summary (collapse)
- - (Object) add_bar_width_and_spacing
- - (Object) encode_data
-
- (BarChart) initialize(options = {})
constructor
:nodoc:.
- - (Object) set_chart_type
Methods included from Markers
Methods included from Grid
Methods included from Axis
Methods included from Fills
Methods included from DataArray
Methods included from Legend
Methods inherited from Base
inherited, #query_params, #size, #size=, #to_url
Constructor Details
- (BarChart) initialize(options = {})
:nodoc:
18 19 20 21 22 23 24 |
# File 'lib/google_chart/bar_chart.rb', line 18 def initialize(={}) #:nodoc: @orientation = :vertical @grouping = :grouped set_chart_type @show_legend = true super() end |
Instance Attribute Details
- (Object) bar_spacing
Returns the value of attribute bar_spacing
13 14 15 |
# File 'lib/google_chart/bar_chart.rb', line 13 def @bar_spacing end |
- (Object) bar_width
Returns the value of attribute bar_width
13 14 15 |
# File 'lib/google_chart/bar_chart.rb', line 13 def @bar_width end |
- (Object) group_spacing
Returns the value of attribute group_spacing
13 14 15 |
# File 'lib/google_chart/bar_chart.rb', line 13 def group_spacing @group_spacing end |
- (Object) grouping
Returns the value of attribute grouping
13 14 15 |
# File 'lib/google_chart/bar_chart.rb', line 13 def grouping @grouping end |
- (Object) orientation
Returns the value of attribute orientation
13 14 15 |
# File 'lib/google_chart/bar_chart.rb', line 13 def orientation @orientation end |
Instance Method Details
- (Object) add_bar_width_and_spacing
67 68 69 70 71 72 |
# File 'lib/google_chart/bar_chart.rb', line 67 def str = "#{@bar_width}" if @bar_width str+= ",#{@bar_spacing}" if @bar_spacing str+= ",#{@group_spacing}" if @group_spacing @params[:chbh] = str if str end |
- (Object) encode_data
74 75 76 77 78 79 80 81 |
# File 'lib/google_chart/bar_chart.rb', line 74 def encode_data # override encode_data to set custom max value for stacked charts (unless max is already set) if grouping == :stacked and not self.max # set max value to the max value of sums self.max = @data.inject(Array.new(@data.first.size,0)) { |sum_series, series| sum_series.zip(series).collect { |d| d.first + d.last } }.max end super end |
- (Object) set_chart_type
39 40 41 42 43 44 45 46 47 |
# File 'lib/google_chart/bar_chart.rb', line 39 def set_chart_type @chart_type = ( if @orientation == :horizontal and @grouping == :grouped then "bhg" elsif @orientation == :horizontal and @grouping == :stacked then "bhs" elsif @orientation == :vertical and @grouping == :grouped then "bvg" elsif @orientation == :vertical and @grouping == :stacked then "bvs" end ) end |