Rails chartkick how to add names

844 views Asked by At

I am using gem 'chartkick' and have such code:

        <%= pie_chart question.responses.group(:answer_variant_id).count %>

the table responses is connected with table answer_variants through answer_variant_id. Currently my pie chart shows answer variant ids, but how could I make it displaying answer_variant.title?

Thanks

1

There are 1 answers

0
Neon_10 On

I resolved this. Needed to join another table. The answer looks like this:

<%= pie_chart question.responses.joins(:answer_variant).group(:title).count %>