lib/write_xlsx/workbook.rb in write_xlsx-0.55.0 vs lib/write_xlsx/workbook.rb in write_xlsx-0.56.0

- old
+ new

@@ -356,13 +356,10 @@ raise "Must define chart type in add_chart()" unless type chart = Chart.factory(type, params[:subtype]) chart.palette = @palette - # Get an incremental id to use for axes ids. - chart.id = @charts.size - # If the chart isn't embedded let the workbook control it. if ptrue?(embedded) chart.name = name if name # Set index to 0 so that the activate() and set_first_sheet() methods @@ -1636,12 +1633,10 @@ chart_count = sheet.charts.size image_count = sheet.images.size shape_count = sheet.shapes.size next if chart_count + image_count + shape_count == 0 - sheet.sort_charts - drawing_id += 1 (0 .. chart_count - 1).each do |index| chart_ref_id += 1 sheet.prepare_chart(index, chart_ref_id, drawing_id) @@ -1662,9 +1657,13 @@ end drawing = sheet.drawing @drawings << drawing end + + # Sort the workbook charts references into the order that the were + # written from the worksheets above. + @charts = @charts.sort_by { |chart| chart.id } @drawing_count = drawing_id end #