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



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

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

#legendBool

Returns decide if the diagram prepare legend

Returns:

  • (Bool)

    decide if the diagram prepare legend



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

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

#valueSymbol

Returns the column label from which bar chart is created

Returns:

  • (Symbol)

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

#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.



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

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

#xSymbol

Returns the column label from which bar chart is created

Returns:

  • (Symbol)

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

#ySymbol

Returns the column label from which bar chart is created

Returns:

  • (Symbol)

    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.

Returns:

  • (Boolean)


75
76
77
# File 'lib/nyaplot/diagram.rb', line 75

def zoom?
  false
end