randym/axlsx

Stacked bar chart plotted as staircased

AdityaTiwari2102 opened this issue · 3 comments

I am using this gem for generating the excel charts on ruby on rails. My requirement is to generate a stacked bar chart but it is generating in a staircase format refer the image here. To generate the chart I have used the following code,

sheet.add_chart(Axlsx::BarChart, start_at: "B5", end_at: "I20", title: "Test Title", grouping: :stacked) do |chart|
    chart.barDir = :col
    chart.add_series(data: sheet["C3:E3"], labels: sheet["C2:E2"], title: sheet["C1"])
    chart.add_series(data: sheet["F3:H3"], labels: sheet["C2:E2"], title: sheet["F1"])
  end

When I manually edit the generated chart in Microsoft Excel and set Series Overlap to 100%, I'm getting the desired output refer the image here.

@randym Request for help

Have you tried chart.grouping = :stacked method? I think it should solve your issue.

@menporulporiayalan - I tried that too, it is not working. Moreover, I have defined the grouping as stacked in add_chart as well (as mentioned in the sample code too), both generated the same result 😢.