Class: D3::Histogram

Inherits:
Object
  • Object
show all
Includes:
Native
Defined in:
lib/opal/d3/histograms.rb

Instance Method Summary collapse

Methods included from Native

included, #initialize

Instance Method Details

#call(data) ⇒ Object



5
6
7
# File 'lib/opal/d3/histograms.rb', line 5

def call(data)
  @native.call(data)
end

#thresholds(count = nil, &block) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/opal/d3/histograms.rb', line 9

def thresholds(count=nil, &block)
  if block_given?
    @native.JS.thresholds(block)
  elsif count.is_a?(Numeric)
    @native.JS.thresholds(count)
  elsif count == :scott
    @native.JS.thresholds{|*args| D3.threshold_scott(*args)}
  elsif count == :sturges
    @native.JS.thresholds{|*args| D3.threshold_sturges(*args)}
  elsif count == :freedman_diaconis
    @native.JS.thresholds{|*args| D3.threshold_freedman_diaconis(*args)}
  else
    raise ArgumentError, "Wrong use of D3::Histogram.thresholds API - pass block, number, or symbol"
  end
  self
end