chartkick icon indicating copy to clipboard operation
chartkick copied to clipboard

Stacked column chart data format not obvious

Open datwright opened this issue 12 years ago • 5 comments

How do you actually need to format data to generate a stacked column chart?

<%= column_chart data, stacked: true %>

This is the hash structure you get when you do something like Task.group(:x).group(:animal).count:

{[x1, "dog"] => 1, [x1, "pig"] => 4, [x2, "dog"] => 3, [x2, "pig"] => 5}

I was hoping that would just work, but no such luck.

Also tried using Google's structure but that didn't work either https://developers.google.com/chart/interactive/docs/gallery/columnchart#StackedColumns

datwright avatar May 22 '14 20:05 datwright

Use the same format as multiple series. I have a branch to support the double group format for #70

ankane avatar May 23 '14 00:05 ankane

Ah, that makes sense! Works like a charm. Thanks!
Looking forward to #70.

datwright avatar May 23 '14 14:05 datwright

This should make things easier.

ankane avatar May 29 '14 08:05 ankane

Can you please give an example of how the data needs to be constructed? I can't seem to create a stacked chart..

guyisra avatar Sep 26 '15 14:09 guyisra

I still can't figure out how to format data for stacked chart. Can someone give an example please?

Thanks.

san avatar May 24 '17 17:05 san