Module: Nyaplot::Diagrams::Bar
- Includes:
- Jsonizable
- Defined in:
- lib/nyaplot/diagram.rb
Instance Attribute Summary collapse
-
#color ⇒ Array<String>
Array of color codes.
-
#value ⇒ Symbol
The column label from which bar chart is created.
-
#width ⇒ Numeric
The width of each bar.
-
#x ⇒ Symbol
The column label from which bar chart is created.
-
#y ⇒ Symbol
The column label from which bar chart is created.
Instance Method Summary collapse
-
#process_data(df, labels) ⇒ Object
calcurate xrange and yrange from recieved data.
-
#zoom? ⇒ Boolean
internal use.
Methods included from Jsonizable
#before_to_json, #get_property, included, #init_properties, #set_property, #to_json
Instance Attribute Details
#color ⇒ Array<String>
Returns array of color codes.
52 |
# File 'lib/nyaplot/diagram.rb', line 52 define_group_properties(:options, [:value, :x, :y, :width, :color]) |
#value ⇒ Symbol
Returns the column label from which bar chart is created.
52 |
# File 'lib/nyaplot/diagram.rb', line 52 define_group_properties(:options, [:value, :x, :y, :width, :color]) |
#width ⇒ Numeric
Returns the width of each bar. The specified value should be in the range 0 to 1.
52 |
# File 'lib/nyaplot/diagram.rb', line 52 define_group_properties(:options, [:value, :x, :y, :width, :color]) |
#x ⇒ Symbol
Returns the column label from which bar chart is created.
52 |
# File 'lib/nyaplot/diagram.rb', line 52 define_group_properties(:options, [:value, :x, :y, :width, :color]) |
#y ⇒ Symbol
Returns the column label from which bar chart is created.
52 |
# File 'lib/nyaplot/diagram.rb', line 52 define_group_properties(:options, [:value, :x, :y, :width, :color]) |
Instance Method Details
#process_data(df, labels) ⇒ Object
calcurate xrange and yrange from recieved data
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/nyaplot/diagram.rb', line 55 def process_data(df, labels) case labels.length when 1 label = labels[0] value(label) @xrange = df[label].to_a.uniq @yrange = [0, df[label].to_a.length] when 2 label_x = labels[0] label_y = labels[1] x(label_x) y(label_y) @xrange = df.column(label_x).to_a @yrange = [(df[label_y].to_a.min < 0 ? df[label_y].to_a.min : 0), df[label_y].to_a.max] end end |
#zoom? ⇒ Boolean
internal use. Nyaplot::Plot asks diagram through this method whether to enable zooming option or not.
73 74 75 |
# File 'lib/nyaplot/diagram.rb', line 73 def zoom? false end |