Class: Gruff::Pie
Overview
Direct Known Subclasses
Constant Summary collapse
- DEFAULT_TEXT_OFFSET_PERCENTAGE =
0.15
Constants inherited from Base
Base::DEFAULT_MARGIN, Base::DEFAULT_TARGET_WIDTH, Base::LABEL_MARGIN, Base::LEGEND_MARGIN, Base::THOUSAND_SEPARATOR
Instance Attribute Summary collapse
- #hide_labels_less_than ⇒ Object
-
#show_values_as_labels ⇒ Object
Use values instead of percentages.
- #text_offset_percentage ⇒ Object
- #zero_degree ⇒ Object
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_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
#hide_labels_less_than ⇒ Object
46 47 48 |
# File 'lib/gruff/pie.rb', line 46 def hide_labels_less_than @hide_labels_less_than ||= 0.0 end |
#show_values_as_labels ⇒ Object
Use values instead of percentages.
31 32 33 |
# File 'lib/gruff/pie.rb', line 31 def show_values_as_labels @show_values_as_labels end |
#text_offset_percentage ⇒ Object
50 51 52 |
# File 'lib/gruff/pie.rb', line 50 def text_offset_percentage @text_offset_percentage ||= DEFAULT_TEXT_OFFSET_PERCENTAGE end |
#zero_degree ⇒ Object
42 43 44 |
# File 'lib/gruff/pie.rb', line 42 def zero_degree @zero_degree ||= 0.0 end |
Instance Method Details
#draw ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/gruff/pie.rb', line 63 def draw hide_line_markers super return unless data_given? slices.each do |slice| if slice.value > 0 Gruff::Renderer::Ellipse.new(color: slice.color, width: radius) .render(center_x, center_y, radius / 2.0, radius / 2.0, chart_degrees, chart_degrees + slice.degrees + 0.5) process_label_for slice update_chart_degrees_with slice.degrees end end Gruff::Renderer.finish end |
#options ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/gruff/pie.rb', line 54 def { zero_degree: zero_degree, hide_labels_less_than: hide_labels_less_than, text_offset_percentage: text_offset_percentage, show_values_as_labels: show_values_as_labels } end |