Class: GChart::Bar

Inherits:
Base
  • Object
show all
Defined in:
lib/gchart/bar.rb

Constant Summary collapse

ORIENTATIONS =
[:horizontal, :vertical]

Instance Attribute Summary collapse

Attributes inherited from Base

#axes, #chart_background, #colors, #data, #entire_background, #extras, #height, #legend, #max, #title, #width

Instance Method Summary collapse

Methods inherited from Base

#axis, #fetch, #size, #size=, #to_url, #write

Constructor Details

#initialize(*args, &block) ⇒ Bar

Returns a new instance of Bar.



13
14
15
16
17
# File 'lib/gchart/bar.rb', line 13

def initialize(*args, &block)
  @grouped = false
  @orientation = :horizontal
  super
end

Instance Attribute Details

#groupedObject Also known as: grouped?

Returns the value of attribute grouped.



5
6
7
# File 'lib/gchart/bar.rb', line 5

def grouped
  @grouped
end

#orientationObject

Returns the value of attribute orientation.



8
9
10
# File 'lib/gchart/bar.rb', line 8

def orientation
  @orientation
end

#spacingObject

Returns the value of attribute spacing.



11
12
13
# File 'lib/gchart/bar.rb', line 11

def spacing
  @spacing
end

#thicknessObject

Returns the value of attribute thickness.



10
11
12
# File 'lib/gchart/bar.rb', line 10

def thickness
  @thickness
end

Instance Method Details

#horizontal?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/gchart/bar.rb', line 28

def horizontal?
  @orientation == :horizontal
end

#query_params(params = {}) ⇒ Object

overrides GChart::Base#query_params



47
48
49
50
51
52
53
54
# File 'lib/gchart/bar.rb', line 47

def query_params(params={}) #:nodoc:
  values = []
  values << thickness if thickness
  values << spacing if thickness && spacing
  
  params["chbh"] = values.join(",") unless values.empty?
  super(params)
end

#render_chart_typeObject

:nodoc:



56
57
58
# File 'lib/gchart/bar.rb', line 56

def render_chart_type #:nodoc:
  "b#{@orientation.to_s[0..0]}#{grouped? ? "g" : "s"}"
end

#vertical?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/gchart/bar.rb', line 32

def vertical?
  @orientation == :vertical
end