Class: Writexlsx::Chart::Pie
- Inherits:
-
Writexlsx::Chart
- Object
- Writexlsx::Chart
- Writexlsx::Chart::Pie
- Includes:
- Utility
- Defined in:
- lib/write_xlsx/chart/pie.rb
Overview
A Pie chart doesn’t have an X or Y axis so the following common chart methods are ignored.
chart.set_x_axis
chart.set_y_axis
Constant Summary
Constants included from Utility
Utility::COL_MAX, Utility::ROW_MAX, Utility::SHEETNAME_MAX, Utility::STR_MAX
Instance Attribute Summary
Attributes inherited from Writexlsx::Chart
#embedded, #formula_data, #formula_ids, #height, #id, #index, #name, #palette, #protection, #width, #x_offset, #x_scale, #y_offset, #y_scale
Instance Method Summary collapse
-
#initialize(subtype) ⇒ Pie
constructor
A new instance of Pie.
-
#write_a_p_legend(font) ⇒ Object
Write the <a:p> element for legends.
-
#write_a_p_pr_legend(font) ⇒ Object
Write the <a:pPr> element for legends.
-
#write_chart_type ⇒ Object
Override the virtual superclass method with a chart specific method.
-
#write_first_slice_ang ⇒ Object
Write the <c:firstSliceAng> element.
-
#write_legend ⇒ Object
Over-ridden method to add <c:txPr> to legend.
-
#write_pie_chart ⇒ Object
Write the <c:pieChart> element.
-
#write_plot_area ⇒ Object
Over-ridden method to remove the cat_axis() and val_axis() code since Pie charts don’t require those axes.
-
#write_tx_pr_legend(horiz, font) ⇒ Object
Write the <c:txPr> element for legends.
-
#write_vary_colors ⇒ Object
Write the <c:varyColors> element.
Methods included from Utility
#absolute_char, #check_dimensions, #check_dimensions_and_update_max_min_values, #check_parameter, #convert_date_time, #dash_types, delete_files, #fill_properties, #float_to_str, #layout_properties, #line_fill_properties, #line_properties, #palette_color, #pixels_to_points, #ptrue?, #put_deprecate_message, #r_id_attributes, #row_col_notation, #shape_style_base, #store_col_max_min_values, #store_row_max_min_values, #substitute_cellref, #underline_attributes, #v_shape_attributes_base, #v_shape_style_base, #value_or_raise, #write_anchor, #write_auto_fill, #write_color, #write_comment_path, #write_div, #write_fill, #write_font, #write_stroke, #write_xml_declaration, #xl_cell_to_rowcol, #xl_col_to_name, #xl_range, #xl_range_formula, #xl_rowcol_to_cell, #xml_str
Methods inherited from Writexlsx::Chart
#add_series, #assemble_xml_file, #convert_font_args, #data_id, factory, #params_to_font, #process_names, #set_chartarea, #set_drop_lines, #set_embedded_config_data, #set_high_low_lines, #set_legend, #set_plotarea, #set_size, #set_style, #set_table, #set_title, #set_up_down_bars, #set_x2_axis, #set_x_axis, #set_xml_writer, #set_y2_axis, #set_y_axis, #show_blanks_as, #show_hidden_data, #write_bar_chart
Constructor Details
#initialize(subtype) ⇒ Pie
Returns a new instance of Pie.
29 30 31 |
# File 'lib/write_xlsx/chart/pie.rb', line 29 def initialize(subtype) super(subtype) end |
Instance Method Details
#write_a_p_legend(font) ⇒ Object
Write the <a:p> element for legends.
129 130 131 132 133 134 135 136 |
# File 'lib/write_xlsx/chart/pie.rb', line 129 def write_a_p_legend(font) @writer.tag_elements('a:p') do # Write the a:pPr element. write_a_p_pr_legend(font) # Write the a:endParaRPr element. write_a_end_para_rpr end end |
#write_a_p_pr_legend(font) ⇒ Object
Write the <a:pPr> element for legends.
141 142 143 144 145 146 |
# File 'lib/write_xlsx/chart/pie.rb', line 141 def write_a_p_pr_legend(font) @writer.tag_elements('a:pPr', [ ['rtl', 0] ]) do # Write the a:defRPr element. write_a_def_rpr(font) end end |
#write_chart_type ⇒ Object
Override the virtual superclass method with a chart specific method.
36 37 38 39 |
# File 'lib/write_xlsx/chart/pie.rb', line 36 def write_chart_type # Write the c:areaChart element. write_pie_chart end |
#write_first_slice_ang ⇒ Object
Write the <c:firstSliceAng> element.
158 159 160 |
# File 'lib/write_xlsx/chart/pie.rb', line 158 def write_first_slice_ang @writer.empty_tag('c:firstSliceAng', [ ['val', 0] ]) end |
#write_legend ⇒ Object
Over-ridden method to add <c:txPr> to legend.
Write the <c:legend> element.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/write_xlsx/chart/pie.rb', line 76 def write_legend position = @legend_position allowed = %w(right left top bottom) delete_series = @legend_delete_series || [] if @legend_position =~ /^overlay_/ position = @legend_position.sub(/^overlay_/, '') = true else position = @legend_position = false end return if position == 'none' return unless allowed.include?(position) @writer.tag_elements('c:legend') do # Write the c:legendPos element. write_legend_pos(position[0]) # Remove series labels from the legend. # Write the c:legendEntry element. delete_series.each { |index| write_legend_entry(index) } # Write the c:layout element. write_layout(@legend_layout, 'legend') # Write the c:overlay element. if # Write the c:txPr element. Over-ridden. write_tx_pr_legend(0, @legend_font) end end |
#write_pie_chart ⇒ Object
Write the <c:pieChart> element. Over-ridden method to remove axis_id code since pie charts don’t require val and vat axes.
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/write_xlsx/chart/pie.rb', line 45 def write_pie_chart @writer.tag_elements('c:pieChart') do # Write the c:varyColors element. write_vary_colors # Write the series elements. @series.each {|s| write_series(s)} # Write the c:firstSliceAng element. write_first_slice_ang end end |
#write_plot_area ⇒ Object
Over-ridden method to remove the cat_axis() and val_axis() code since Pie charts don’t require those axes.
Write the <c:plotArea> element.
62 63 64 65 66 67 68 69 |
# File 'lib/write_xlsx/chart/pie.rb', line 62 def write_plot_area @writer.tag_elements('c:plotArea') do # Write the c:layout element. write_layout(@plotarea.layout, 'plot') # Write the subclass chart type element. write_chart_type end end |
#write_tx_pr_legend(horiz, font) ⇒ Object
Write the <c:txPr> element for legends.
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/write_xlsx/chart/pie.rb', line 110 def write_tx_pr_legend(horiz, font) rotation = nil if ptrue?(font) && font[:_rotation] rotation = font[:_rotation] end @writer.tag_elements('c:txPr') do # Write the a:bodyPr element. write_a_body_pr(rotation, horiz) # Write the a:lstStyle element. write_a_lst_style # Write the a:p element. write_a_p_legend(font) end end |
#write_vary_colors ⇒ Object
Write the <c:varyColors> element.
151 152 153 |
# File 'lib/write_xlsx/chart/pie.rb', line 151 def write_vary_colors @writer.empty_tag('c:varyColors', [ ['val', 1] ]) end |