Sha256: 9244bdc35013127f38ceed62b4f4704b783c6fbaafd34239b6631623f1ab2813

Contents?: true

Size: 761 Bytes

Versions: 6

Compression:

Stored size: 761 Bytes

Contents

module D3
  class OrdinalScale
    include D3::Native

    def call(t)
      @native.call(t)
    end
    attributes_d3 %i[domain range]
    alias_native_new :copy

    # D3 is trying to reinvent Ruby symbols here
    def unknown(new_value=nil)
      if new_value == nil
        v = @native.JS.unknown
        if `JSON.stringify(v) === '{"name":"implicit"}'`
          :implicit
        else
          v
        end
      else
        if new_value == :implicit
          new_value = `window.d3.scaleImplicit`
        end
        @native.JS.unknown(new_value)
        self
      end
    end
  end

  class << self
    def scale_ordinal(*args)
      D3::OrdinalScale.new @d3.JS.scaleOrdinal(*args)
    end

    def scale_implicit
      :implicit
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
hyper-d3-1.0.0.lap28 lib/d3/ordinal_scale.rb
hyper-d3-1.0.0.lap27 lib/d3/ordinal_scale.rb
hyper-d3-1.0.0.lap26 lib/d3/ordinal_scale.rb
hyper-d3-1.0.0.lap25 lib/d3/ordinal_scale.rb
hyper-d3-1.0.0.lap24 lib/d3/ordinal_scale.rb
hyper-d3-1.0.0.lap23 lib/d3/ordinal_scale.rb