Module: Nyaplot::Diagrams::Bar

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Jsonizable

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

Instance Attribute Details

#colorArray<String>

Returns array of color codes.

Returns:

  • (Array<String>)

    array of color codes



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

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

#valueSymbol

Returns the column label from which bar chart is created.

Returns:

  • (Symbol)

    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])

#widthNumeric

Returns the width of each bar. The specified value should be in the range 0 to 1.

Returns:

  • (Numeric)

    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])

#xSymbol

Returns the column label from which bar chart is created.

Returns:

  • (Symbol)

    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])

#ySymbol

Returns the column label from which bar chart is created.

Returns:

  • (Symbol)

    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.

Returns:

  • (Boolean)


73
74
75
# File 'lib/nyaplot/diagram.rb', line 73

def zoom?
  false
end