Class: Nyaplot::CircularPlot
- Includes:
- Jsonizable
- Defined in:
- lib/bionya/plot.rb
Instance Attribute Summary collapse
-
#chord ⇒ Boolean
Boolean to decide whether chord is added to the circular plot.
-
#color ⇒ Array<String>
Array of colors.
-
#fill_by ⇒ Symbol
The name of column that decides what colors to be filled in.
-
#inner_radius ⇒ Numeric
The inner radius of circle.
-
#outer_radius ⇒ Numeric
The outer radius of circle.
-
#padding ⇒ Numeric
Padding between two group arcs.
-
#text_color ⇒ String
The color of text.
-
#text_size ⇒ Numeric
The size of text of groups.
Attributes inherited from Plot
#bg_color, #grid_color, #height, #legend, #legend_options, #legend_width, #margin, #rotate_x_label, #rotate_y_label, #width, #x_label, #x_scale, #xrange, #y_label, #y_scale, #yrange, #zoom
Instance Method Summary collapse
-
#add(layer, type, *labels) ⇒ Diagram
Add diagram to the plot.
-
#add_chord(matrix) ⇒ Object
Add chord to the plot.
-
#add_connector_with_df(df, from, to) ⇒ Diagram
Add connector to the plot.
- #before_to_json ⇒ Object
-
#initialize(df, group_label, nested_label) ⇒ CircularPlot
constructor
A new instance of CircularPlot.
Methods included from Jsonizable
#get_property, included, #init_properties, #set_property, #to_json
Methods inherited from Plot
#add_with_df, #configure, #df_list, #export_html, #show, #to_iruby
Constructor Details
#initialize(df, group_label, nested_label) ⇒ CircularPlot
Returns a new instance of CircularPlot.
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/bionya/plot.rb', line 27 def initialize(df, group_label, nested_label) super() @df = df @inner_num = 0 @outer_num = 1 @nested_label = nested_label set_property(:axis_extra_options, {}) group_by(group_label) color(['#253494']) extension('Bionya') end |
Instance Attribute Details
#chord ⇒ Boolean
Returns boolean to decide whether chord is added to the circular plot.
22 |
# File 'lib/bionya/plot.rb', line 22 define_group_properties(:axis_extra_options, [:df_id, :inner_radius, :outer_radius, :group_by, :axis, :chord, :matrix, :inner_num, :outer_num, :color, :text_color, :text_size, :fill_by, :padding]) |
#color ⇒ Array<String>
Returns array of colors.
22 |
# File 'lib/bionya/plot.rb', line 22 define_group_properties(:axis_extra_options, [:df_id, :inner_radius, :outer_radius, :group_by, :axis, :chord, :matrix, :inner_num, :outer_num, :color, :text_color, :text_size, :fill_by, :padding]) |
#fill_by ⇒ Symbol
Returns the name of column that decides what colors to be filled in.
22 |
# File 'lib/bionya/plot.rb', line 22 define_group_properties(:axis_extra_options, [:df_id, :inner_radius, :outer_radius, :group_by, :axis, :chord, :matrix, :inner_num, :outer_num, :color, :text_color, :text_size, :fill_by, :padding]) |
#inner_radius ⇒ Numeric
Returns the inner radius of circle.
22 |
# File 'lib/bionya/plot.rb', line 22 define_group_properties(:axis_extra_options, [:df_id, :inner_radius, :outer_radius, :group_by, :axis, :chord, :matrix, :inner_num, :outer_num, :color, :text_color, :text_size, :fill_by, :padding]) |
#outer_radius ⇒ Numeric
Returns the outer radius of circle.
22 |
# File 'lib/bionya/plot.rb', line 22 define_group_properties(:axis_extra_options, [:df_id, :inner_radius, :outer_radius, :group_by, :axis, :chord, :matrix, :inner_num, :outer_num, :color, :text_color, :text_size, :fill_by, :padding]) |
#padding ⇒ Numeric
Returns padding between two group arcs.
22 |
# File 'lib/bionya/plot.rb', line 22 define_group_properties(:axis_extra_options, [:df_id, :inner_radius, :outer_radius, :group_by, :axis, :chord, :matrix, :inner_num, :outer_num, :color, :text_color, :text_size, :fill_by, :padding]) |
#text_color ⇒ String
Returns the color of text.
22 |
# File 'lib/bionya/plot.rb', line 22 define_group_properties(:axis_extra_options, [:df_id, :inner_radius, :outer_radius, :group_by, :axis, :chord, :matrix, :inner_num, :outer_num, :color, :text_color, :text_size, :fill_by, :padding]) |
#text_size ⇒ Numeric
Returns the size of text of groups.
22 |
# File 'lib/bionya/plot.rb', line 22 define_group_properties(:axis_extra_options, [:df_id, :inner_radius, :outer_radius, :group_by, :axis, :chord, :matrix, :inner_num, :outer_num, :color, :text_color, :text_size, :fill_by, :padding]) |
Instance Method Details
#add(layer, type, *labels) ⇒ Diagram
Add diagram to the plot
63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/bionya/plot.rb', line 63 def add(layer, type, *labels) if(layer>0) @outer_num += 1 elsif @inner_num += 1 end diagram = Diagram.new(@df, type, labels.push(@nested_label)) diagram.layer(layer) @axis = diagram.x self.diagrams.push(diagram) return diagram end |
#add_chord(matrix) ⇒ Object
Add chord to the plot
43 44 45 |
# File 'lib/bionya/plot.rb', line 43 def add_chord(matrix) @matrix = matrix end |
#add_connector_with_df(df, from, to) ⇒ Diagram
Add connector to the plot
52 53 54 55 56 |
# File 'lib/bionya/plot.rb', line 52 def add_connector_with_df(df, from, to) diagram = Diagram.new(df, :connector, [from, to]) self.diagrams.push(diagram) return diagram end |
#before_to_json ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/bionya/plot.rb', line 77 def before_to_json zoom(true) width(800) if width.nil? height(800) if height.nil? inner_num(@inner_num) outer_num(@outer_num) df_id(@df.name) axis(@axis) self.[:axis_extra_options] = end |