ankane / chartkick

Create beautiful JavaScript charts with one line of Ruby
https://chartkick.com
MIT License
6.33k stars 565 forks source link

Allow overiding `chart_json` on ActiveRecord #576

Closed bekicot closed 1 year ago

bekicot commented 3 years ago

Is your feature request related to a problem? Please describe. Consider this class:

class HourlyForecast < ApplicationRecord
  def self.chart_json
    ..
  end
end

p HourlyForecast.where.method(:chart_json).source_location
## Currently
# ["/---/chartkick-4.0.5/lib/chartkick/enumerable.rb", 4]
## Expected
# ["app/models/hourly_forecast, 2]

Something like that.

ankane commented 1 year ago

Hey @bekicot, thanks for reporting, and sorry for the delay. I've updated chart_json to be defined on Array and Hash instead of Enumerable, which fixes this. It'll be part of the Chartkick 5 release.