Sha256: b2b276b16cd8984110872384437e291ec00b99e5d84da5829d67dec342f15967

Contents?: true

Size: 620 Bytes

Versions: 25

Compression:

Stored size: 620 Bytes

Contents

require "chartkick/version"
require "chartkick/helper"
require "chartkick/rails" if defined?(Rails)
require "chartkick/sinatra" if defined?(Sinatra)

module Chartkick
  class << self
    attr_accessor :content_for
    attr_accessor :options
  end
  self.options = {}
end

# for multiple series
# use Enumerable so it can be called on arrays
module Enumerable
  def chart_json
    if is_a?(Hash) && (key = keys.first) && key.is_a?(Array) && key.size == 2
      group_by { |k, _v| k[0] }.map do |name, data|
        {name: name, data: data.map { |k, v| [k[1], v] }}
      end
    else
      self
    end.to_json
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
chartkick-2.3.5 lib/chartkick.rb
chartkick-2.3.4 lib/chartkick.rb
chartkick-2.3.3 lib/chartkick.rb
chartkick-2.3.2 lib/chartkick.rb
chartkick-2.3.1 lib/chartkick.rb
chartkick-2.3.0 lib/chartkick.rb
chartkick-2.2.5 lib/chartkick.rb
chartkick-2.2.4 lib/chartkick.rb
chartkick-2.2.3 lib/chartkick.rb
chartkick-2.2.2 lib/chartkick.rb
chartkick-2.2.1 lib/chartkick.rb
chartkick-2.2.0 lib/chartkick.rb
chartkick-2.1.3 lib/chartkick.rb
chartkick-2.1.2 lib/chartkick.rb
chartkick-2.1.1 lib/chartkick.rb
chartkick-2.1.0 lib/chartkick.rb
chartkick-2.0.2 lib/chartkick.rb
chartkick-2.0.1 lib/chartkick.rb
chartkick-2.0.0 lib/chartkick.rb
chartkick-1.5.2 lib/chartkick.rb