Module: Nyaplot::Diagrams::Bar

Includes:
Jsonizable
Defined in:
lib/nyaplot/diagram.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Jsonizable

#as_json, #before_to_json, #get_property, included, #init_properties, #set_property, #to_json

Instance Attribute Details

#colorArray<String>


54
# File 'lib/nyaplot/diagram.rb', line 54

define_group_properties(:options, [:value, :x, :y, :width, :color, :legend])

#legendBool


54
# File 'lib/nyaplot/diagram.rb', line 54

define_group_properties(:options, [:value, :x, :y, :width, :color, :legend])

#valueSymbol


54
# File 'lib/nyaplot/diagram.rb', line 54

define_group_properties(:options, [:value, :x, :y, :width, :color, :legend])

#widthNumeric


54
# File 'lib/nyaplot/diagram.rb', line 54

define_group_properties(:options, [:value, :x, :y, :width, :color, :legend])

#xSymbol


54
# File 'lib/nyaplot/diagram.rb', line 54

define_group_properties(:options, [:value, :x, :y, :width, :color, :legend])

#ySymbol


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