Darkstarone
Darkstarone

Reputation: 4730

Chartkick/Google charts only using first colour in array on bar graph

I'm using chartkick in rails to produce graphs like this:

<% @graphs.each_with_index do |g, i| %>
    <%= column_chart  g, discrete: true, min: 0.0, max: 1.1, colors: ["pink", "blue", "red"],
    library: {hAxis: {textStyle: {fontSize: 10}}} %>
  <% end %>

Where g is some data like:

[['test1', 0.1],['test2',0.4],['test3',07]]

My problem is that instead of the first three columns being pink, blue, and red, they're all pink!

Does anyone know how to make the bars different colours?

Edit:

Toy example:

  <%= column_chart  [['test1', 20], ['test2', 30],['test3', 30]], colors: ["pink", "red", "blue"] %>

Upvotes: 0

Views: 605

Answers (1)

ramongr
ramongr

Reputation: 55

As seen here https://github.com/ankane/chartkick/issues/77 it's not possible unless you use two series. I would recomend using the Google Charts directly it might solve your problem.

Upvotes: 1

Related Questions