lib/write_xlsx/chart/pie.rb in write_xlsx-0.0.3 vs lib/write_xlsx/chart/pie.rb in write_xlsx-0.0.4

- old
+ new

@@ -41,40 +41,33 @@ # # Write the <c:pieChart> element. # def write_pie_chart - @writer.start_tag('c:pieChart') - - # Write the c:varyColors element. - write_vary_colors - - # Write the series elements. - write_series - - # Write the c:firstSliceAng element. - write_first_slice_ang - - @writer.end_tag('c:pieChart') + @writer.tag_elements('c:pieChart') do + # Write the c:varyColors element. + write_vary_colors + # Write the series elements. + write_series + # Write the c:firstSliceAng element. + write_first_slice_ang + end end # # 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. # def write_plot_area - @writer.start_tag('c:plotArea') - - # Write the c:layout element. - write_layout - - # Write the subclass chart type element. - write_chart_type - - @writer.end_tag('c:plotArea') + @writer.tag_elements('c:plotArea') do + # Write the c:layout element. + write_layout + # Write the subclass chart type element. + write_chart_type + end end # # Over-ridden method to remove axis_id code since Pie charts don't require # val and cat axes. @@ -114,75 +107,61 @@ return if position == 'none' return unless allowed.has_key?(position) position = allowed[position] - @writer.start_tag('c:legend') - - # Write the c:legendPos element. - write_legend_pos(position) - - # Write the c:layout element. - write_layout - - # Write the c:overlay element. - write_overlay if overlay != 0 - - # Write the c:txPr element. Over-ridden. - write_tx_pr_legend - - @writer.end_tag('c:legend') + @writer.tag_elements('c:legend') do + # Write the c:legendPos element. + write_legend_pos(position) + # Write the c:layout element. + write_layout + # Write the c:overlay element. + write_overlay if overlay != 0 + # Write the c:txPr element. Over-ridden. + write_tx_pr_legend + end end # # Write the <c:txPr> element for legends. # def write_tx_pr_legend horiz = 0 - @writer.start_tag('c:txPr') - - # Write the a:bodyPr element. - write_a_body_pr(horiz) - - # Write the a:lstStyle element. - write_a_lst_style - - # Write the a:p element. - write_a_p_legend - - @writer.end_tag('c:txPr') + @writer.tag_elements('c:txPr') do + # Write the a:bodyPr element. + write_a_body_pr(horiz) + # Write the a:lstStyle element. + write_a_lst_style + # Write the a:p element. + write_a_p_legend + end end # # Write the <a:p> element for legends. # def write_a_p_legend - @writer.start_tag('a:p') - - # Write the a:pPr element. - write_a_p_pr_legend - - # Write the a:endParaRPr element. - write_a_end_para_rpr - - @writer.end_tag('a:p') + @writer.tag_elements('a:p') do + # Write the a:pPr element. + write_a_p_pr_legend + # Write the a:endParaRPr element. + write_a_end_para_rpr + end end # # Write the <a:pPr> element for legends. # def write_a_p_pr_legend rtl = 0 attributes = ['rtl', rtl] - @writer.start_tag('a:pPr', attributes) - - # Write the a:defRPr element. - write_a_def_rpr - - @writer.end_tag('a:pPr') + @writer.tag_elements('a:pPr', attributes) do + # Write the a:defRPr element. + write_a_def_rpr + end end # # Write the <c:varyColors> element. #