Module: Nyaplot::Diagrams::Arc

Includes:
Jsonizable
Defined in:
lib/bionya/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

#axisBoolean

Returns Boolean whether to render axis along arcs.

Returns:

  • (Boolean)

    Boolean whether to render axis along arcs



17
# File 'lib/bionya/diagram.rb', line 17

define_group_properties(:options, [:range, :width, :color, :fill_by, :x, :y, :layer, :axis])

#colorArray<String>

Returns colors in which arcs are filled.

Returns:

  • (Array<String>)

    colors in which arcs are filled



17
# File 'lib/bionya/diagram.rb', line 17

define_group_properties(:options, [:range, :width, :color, :fill_by, :x, :y, :layer, :axis])

#fill_bySymbol

Returns the column label to decide how to fill sybmols.

Returns:

  • (Symbol)

    the column label to decide how to fill sybmols



17
# File 'lib/bionya/diagram.rb', line 17

define_group_properties(:options, [:range, :width, :color, :fill_by, :x, :y, :layer, :axis])

#layerNumeric

Returns The number of layer where the plot is placed.

Returns:

  • (Numeric)

    The number of layer where the plot is placed



17
# File 'lib/bionya/diagram.rb', line 17

define_group_properties(:options, [:range, :width, :color, :fill_by, :x, :y, :layer, :axis])

#rangeArray<Numeric>

Returns The range of values on y-axis.

Returns:

  • (Array<Numeric>)

    The range of values on y-axis



17
# File 'lib/bionya/diagram.rb', line 17

define_group_properties(:options, [:range, :width, :color, :fill_by, :x, :y, :layer, :axis])

#widthNumeric

Returns The width of bars [0..1].

Returns:

  • (Numeric)

    The width of bars [0..1]



17
# File 'lib/bionya/diagram.rb', line 17

define_group_properties(:options, [:range, :width, :color, :fill_by, :x, :y, :layer, :axis])

Instance Method Details

#process_data(df, labels) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/bionya/diagram.rb', line 19

def process_data(df, labels)
  x(labels[0])
  y(labels[1])

  nested = df.column(labels[2]) # 'nested_label' column from CircularPlot
  raise 'received dataframe is not nested' unless nested.all? {|cell| cell.is_a? DataFrame}
  max = nested.reduce(-Float::INFINITY){|memo, df| [memo, df.column(y).max].max}
  min = nested.reduce(Float::INFINITY){|memo, df| [memo, df.column(y).min].min}
  if min > 0
    range([0, max])
  else
    range([min, max])
  end
end