【问题标题】:How to show only integers in YAxis in chartkick如何在chartkick中仅显示YAxis中的整数
【发布时间】:2016-11-16 19:46:03
【问题描述】:

我只想在 YAxis 中显示整数

PaymentTransaction.group_by_day(:created_at, format: "%b %d, %Y").count,discrete: true, allowDecimals: false,yAxis: {allowDecimals: false}

【问题讨论】:

    标签: ruby-on-rails ruby charts chartkick


    【解决方案1】:

    如果你使用谷歌图表,那么你可以这样做:

    data = PaymentTransaction.group_by_day(:created_at, format: "%b %d, %Y").count
    y = data.map(&:last)
    y_discrete = ((y.min.floor)..(y.max.ceil)).to_a
    options = { vAxis: { ticks: y_discrete } }
    line_chart(data, { library: options })
    

    【讨论】:

      猜你喜欢
      • 2012-12-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多