Sha256: 45829bfbaece5feb4578ab026ac9c4d2be57d35711724dd46d3653202fda23b3

Contents?: true

Size: 1.18 KB

Versions: 8

Compression:

Stored size: 1.18 KB

Contents

describe "d3-array - histograms" do
  it "d3.histogram" do
    expect(D3.histogram).to be_a(D3::Histogram)
  end

  describe "histogram.thresholds" do
    let(:data) { (1..10).to_a }
    let(:h) { D3.histogram }
    it "block" do
      h.thresholds{|*args| D3.threshold_sturges(*args) }
      expect(h.(data)).to eq([
        [1],
        [2,3],
        [4,5],
        [6,7],
        [8,9,10]
      ])
    end

    it "symbol" do
      h.thresholds(:scott)
      expect(h.(data)).to eq([
        [1,2,3,4],
        [5,6,7,8,9,10],
      ])
    end

    it "number" do
      h.thresholds(2)
      expect(h.(data)).to eq([
        [1, 2, 3, 4],
        [5, 6, 7, 8, 9, 10]
      ])
    end
  end

  it "histogram.call" do
    h = D3.histogram
    expect(h.([1,2,1,2,1,3])).to eq([
      [1,1,1],
      [],
      [2,2],
      [3],
    ])
  end

  it "d3.threshold_freedman_diaconis" do
    data = (0..10).to_a
    expect(D3.threshold_freedman_diaconis(data,0,10)).to eq(3)
  end

  it "d3.threshold_scott" do
    data = (0..10).to_a
    expect(D3.threshold_scott(data,0,10)).to eq(2)
  end

  it "d3.threshold_sturges" do
    data = (0..10).to_a
    expect(D3.threshold_sturges(data,0,10)).to eq(5)
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
hyper-d3-1.0.0.lap28 spec/histograms_spec.rb
hyper-d3-1.0.0.lap27 spec/histograms_spec.rb
hyper-d3-1.0.0.lap26 spec/histograms_spec.rb
hyper-d3-1.0.0.lap25 spec/histograms_spec.rb
hyper-d3-1.0.0.lap24 spec/histograms_spec.rb
hyper-d3-1.0.0.lap23 spec/histograms_spec.rb
opal-d3-0.0.20170822 spec/histograms_spec.rb
opal-d3-0.0.20170205 spec/histograms_spec.rb