Sha256: c74d4367c115fab1abecfd258c00222a2e9ff4267a127cda3e6b2588934ca449

Contents?: true

Size: 917 Bytes

Versions: 4

Compression:

Stored size: 917 Bytes

Contents

module Vega
  class LiteChart < BaseChart
    # https://vega.github.io/vega-lite/docs/spec.html
    scalar_methods \
      :background, :padding, :autosize, :title, :name, :description, :width, :height, :mark, :spec, :repeat

    hash_methods \
      :config, :usermeta, :projection, :datasets, :encoding, :facet, :resolve, :selection, :view

    array_methods \
      :transform, :layer, :hconcat, :vconcat, :concat, :params

    def initialize
      @schema = "https://vega.github.io/schema/vega-lite/v5.json"
      super()
    end

    def data!(value)
      @spec[:data] = data_value(value)
      self
    end
    immutable_method :data

    undef spec
    def spec(*args)
      if args.empty?
        @spec
      else
        dup.spec!(*args)
      end
    end

    def to_png
      export("vl2png")
    end

    def to_svg
      export("vl2svg")
    end

    def to_pdf
      export("vl2pdf")
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vega-0.4.0 lib/vega/lite_chart.rb
vega-0.3.2 lib/vega/lite_chart.rb
vega-0.3.1 lib/vega/lite_chart.rb
vega-0.3.0 lib/vega/lite_chart.rb