【问题标题】:Chartkick/Google charts only using first colour in array on bar graphChartkick/Google 图表仅使用条形图数组中的第一种颜色
【发布时间】:2014-09-03 01:45:16
【问题描述】:

我在 rails 中使用 chartkick 来生成这样的图表:

<% @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 %>

其中 g 是一些数据,例如:

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

我的问题是,前三列不是粉红色、蓝色和红色,而是全是粉红色!

有谁知道如何让条带变成不同的颜色?

编辑:

玩具示例:

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

【问题讨论】:

    标签: ruby-on-rails google-visualization chartkick


    【解决方案1】:

    如此处https://github.com/ankane/chartkick/issues/77 所见,除非您使用两个系列,否则这是不可能的。我建议直接使用 Google Charts,它可能会解决您的问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-02-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-04
      相关资源
      最近更新 更多