class ChartJS::Dataset
Public Class Methods
new(label, &block)
click to toggle source
# File lib/chart_js/chart/bar_chart/dataset.rb, line 10 def initialize(label, &block) @container = Hash.new fill(false) label(label) build(&block) end
Public Instance Methods
axis_id(value, axis)
click to toggle source
# File lib/chart_js/chart/bar_chart/dataset.rb, line 34 def axis_id(value, axis) case axis when :x @container['xAxisID'] = value when :y @container['yAxisID'] = value end end
background(&block)
click to toggle source
# File lib/chart_js/chart/bar_chart/dataset.rb, line 65 def background(&block) @container = Background.new(@container).build(&block) end
border(&block)
click to toggle source
# File lib/chart_js/chart/bar_chart/dataset.rb, line 69 def border(&block) @container = Border.new(@container).build(&block) end
build(&block)
click to toggle source
# File lib/chart_js/chart/bar_chart/dataset.rb, line 17 def build(&block) instance_eval(&block) @container end
color(value = :random, type = :both)
click to toggle source
# File lib/chart_js/chart/bar_chart/dataset.rb, line 43 def color(value = :random, type = :both) if value == :random c = "##{SecureRandom.hex(3)}" color c, :border if type == :both || type == :border color c, :background if type == :both || type == :background return end case type when :border @container['borderColor'] = value when :background @container['backgroundColor'] = value when :both color value, :border color value, :background end end
data(value)
click to toggle source
# File lib/chart_js/chart/bar_chart/dataset.rb, line 22 def data(value) @container['data'] = value end
fill(value = true)
click to toggle source
# File lib/chart_js/chart/bar_chart/dataset.rb, line 30 def fill(value = true) @container['fill'] = value end
label(value)
click to toggle source
# File lib/chart_js/chart/bar_chart/dataset.rb, line 26 def label(value) @container['label'] = value end
line(&block)
click to toggle source
# File lib/chart_js/chart/bar_chart/dataset.rb, line 77 def line(&block) @container = Line.new(@container).build(&block) end
method_missing(m, *args, &block)
click to toggle source
# File lib/chart_js/chart/dataset.rb, line 22 def method_missing(m, *args, &block) m = m.to_s if m.to_s.include?('_') parts = m.split('_').collect(&:capitalize) parts[0] = parts[0].downcase m = parts.join end @container[m] = args.first end
point(&block)
click to toggle source
# File lib/chart_js/chart/bar_chart/dataset.rb, line 73 def point(&block) @container = Point.new(@container).build(&block) end
span_gaps(value = true)
click to toggle source
# File lib/chart_js/chart/bar_chart/dataset.rb, line 61 def span_gaps(value = true) @container['spanGaps'] = value end
to_h()
click to toggle source
# File lib/chart_js/chart/bar_chart/dataset.rb, line 81 def to_h @container end