Rails动态Highcharts堆栈栏名称

时间:2019-04-26 03:25:45

标签: ruby-on-rails highcharts chartkick

每个栏都有动态名称吗?

目前我有类似下面的内容。每个栏的名称均相同。 stacked bar chart

如果您可以看到我想要年龄段图表。在13-18组中,我想要名称/工具提示13、14、15、16,但在19-23栏中,我想要名称/工具提示19、20、21、22、23,依此类推。可以创建这样的东西吗?

下面是我当前的迭代数据代码。

 @i = 0
    @data = []
    while @i < 12
      @data << {
        name: @i,
          data: [["1-12", Contact.where(contact_group_id: @database.id).where.not("data ->> :key iLIKE :value", key: "phone", value: "#{@i}").size],
                       ["13-18", 16],
                       ["19-23", 28],
                       ["24-28", 16],
                       ["29-35", 28],
                       ["36-42", 16],
                       ["43-50", 28],
                       [">50", 28]]}
      @i += 1
    end

0 个答案:

没有答案
相关问题