lib/write_xlsx/chart/pie.rb in write_xlsx-1.00.0 vs lib/write_xlsx/chart/pie.rb in write_xlsx-1.01.0

- old
+ new

@@ -6,11 +6,11 @@ # Used in conjunction with Chart. # # See formatting note in Chart. # # Copyright 2000-2011, John McNamara, jmcnamara@cpan.org -# Convert to ruby by Hideo NAKAMURA, cxn03651@msj.biglobe.ne.jp +# Convert to ruby by Hideo NAKAMURA, nakamura.hideo@gmail.com # require 'write_xlsx/package/xml_writer_simple' require 'write_xlsx/chart' require 'write_xlsx/utility' @@ -41,17 +41,10 @@ 'best_fit' => 'bestFit' } end # - # Override parent method to add a warning. - # - def combine(chart) - raise "Combined chart not currently supported for Pie charts" - end - - # # Set the Pie/Doughnut chart rotation: the angle of the first slice. # def set_rotation(rotation) return unless rotation if rotation >= 0 && rotation <= 360 @@ -89,14 +82,34 @@ # Pie/Doughnut charts don't require those axes. # # Write the <c:plotArea> element. # def write_plot_area + second_chart = @combined + @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 + # Configure a combined chart if present. + if second_chart + # Secondary axis has unique id otherwise use same as primary. + if second_chart.is_secondary? + second_chart.id = 1000 + @id + else + second_chart.id = @id + end + + # Share the same filehandle for writing + second_chart.writer = @writer + + # Share series index with primary chart. + second_chart.series_index = @series_index + + # Write the subclass chart type elements for combined chart. + second_chart.write_chart_type + end # Write the c:spPr eleent for the plotarea formatting. write_sp_pr(@plotarea) end end