Class: Gruff::Net
Overview
Experimental!!! See also the Spider graph.
Constant Summary
Constants inherited from Base
Base::DEFAULT_MARGIN, Base::DEFAULT_TARGET_WIDTH, Base::LABEL_MARGIN, Base::LEGEND_MARGIN, Base::THOUSAND_SEPARATOR
Instance Attribute Summary collapse
-
#dot_radius ⇒ Object
Returns the value of attribute dot_radius.
-
#hide_dots ⇒ Object
Hide parts of the graph to fit more datapoints, or for a different appearance.
-
#line_width ⇒ Object
Dimensions of lines and dots; calculated based on dataset size if left unspecified.
Attributes inherited from Base
#additional_line_values, #bold_title, #bottom_margin, #center_labels_over_point, #colors, #font, #font_color, #has_left_labels, #hide_legend, #hide_line_markers, #hide_line_numbers, #hide_title, #label_max_size, #label_stagger_height, #label_truncation_style, #labels, #left_margin, #legend_at_bottom, #legend_box_size, #legend_font_size, #legend_margin, #marker_color, #marker_count, #marker_font_size, #marker_shadow_color, #maximum_value, #minimum_value, #no_data_message, #right_margin, #sort, #sorted_drawing, #title, #title_font, #title_font_size, #title_margin, #top_margin, #use_data_label, #x_axis_increment, #x_axis_label, #y_axis_increment, #y_axis_label
Instance Method Summary collapse
Methods inherited from Base
#add_color, #data, #initialize, #margins=, #replace_colors, #theme=, #theme_37signals, #theme_greyscale, #theme_keynote, #theme_odeo, #theme_pastel, #theme_rails_keynote, #to_blob, #write
Constructor Details
This class inherits a constructor from Gruff::Base
Instance Attribute Details
#dot_radius ⇒ Object
Returns the value of attribute dot_radius.
12 13 14 |
# File 'lib/gruff/net.rb', line 12 def dot_radius @dot_radius end |
#hide_dots ⇒ Object
Hide parts of the graph to fit more datapoints, or for a different appearance.
8 9 10 |
# File 'lib/gruff/net.rb', line 8 def hide_dots @hide_dots end |
#line_width ⇒ Object
Dimensions of lines and dots; calculated based on dataset size if left unspecified.
11 12 13 |
# File 'lib/gruff/net.rb', line 11 def line_width @line_width end |
Instance Method Details
#draw ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/gruff/net.rb', line 23 def draw super return unless data_given? stroke_width = line_width || clip_value_if_greater_than(@columns / (store.norm_data.first.points.size * 4), 5.0) circle_radius = dot_radius || clip_value_if_greater_than(@columns / (store.norm_data.first.points.size * 2.5), 5.0) store.norm_data.each do |data_row| data_row.points.each_with_index do |data_point, index| next if data_point.nil? rad_pos = index * Math::PI * 2 / column_count point_distance = data_point * @radius start_x = @center_x + Math.sin(rad_pos) * point_distance start_y = @center_y - Math.cos(rad_pos) * point_distance next_index = index + 1 < data_row.points.length ? index + 1 : 0 next_rad_pos = next_index * Math::PI * 2 / column_count next_point_distance = data_row.points[next_index] * @radius end_x = @center_x + Math.sin(next_rad_pos) * next_point_distance end_y = @center_y - Math.cos(next_rad_pos) * next_point_distance Gruff::Renderer::Line.new(color: data_row.color, width: stroke_width).render(start_x, start_y, end_x, end_y) Gruff::Renderer::Circle.new(color: data_row.color, width: stroke_width).render(start_x, start_y, start_x - circle_radius, start_y) unless @hide_dots end end Gruff::Renderer.finish end |