Module: Nyaplot::Diagrams::Bar
- Includes:
- Jsonizable
- Defined in:
- lib/nyaplot/diagram.rb
Instance Attribute Summary collapse
-
#color ⇒ Array<String>
Array of color codes.
-
#legend ⇒ Bool
Decide if the diagram prepare legend.
-
#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.
54 |
# File 'lib/nyaplot/diagram.rb', line 54 define_group_properties(:options, [:value, :x, :y, :width, :color, :legend]) |
#legend ⇒ Bool
Returns decide if the diagram prepare legend.
54 |
# File 'lib/nyaplot/diagram.rb', line 54 define_group_properties(:options, [:value, :x, :y, :width, :color, :legend]) |
#value ⇒ Symbol
Returns the column label from which bar chart is created.
54 |
# File 'lib/nyaplot/diagram.rb', line 54 define_group_properties(:options, [:value, :x, :y, :width, :color, :legend]) |
#width ⇒ Numeric
Returns the width of each bar. The specified value should be in the range 0 to 1.
54 |
# File 'lib/nyaplot/diagram.rb', line 54 define_group_properties(:options, [:value, :x, :y, :width, :color, :legend]) |
#x ⇒ Symbol
Returns the column label from which bar chart is created.
54 |
# File 'lib/nyaplot/diagram.rb', line 54 define_group_properties(:options, [:value, :x, :y, :width, :color, :legend]) |
#y ⇒ Symbol
Returns the column label from which bar chart is created.
54 |
# File 'lib/nyaplot/diagram.rb', line 54 define_group_properties(:options, [:value, :x, :y, :width, :color, :legend]) |
Instance Method Details
#process_data(df, labels) ⇒ Object
calcurate xrange and yrange from recieved data
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/nyaplot/diagram.rb', line 57 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.
75 76 77 |
# File 'lib/nyaplot/diagram.rb', line 75 def zoom? false end |