Sha256: d9b15eae7edb67b162a7d61959fb5f07b8be1cb67ddc30af5e3434df36e57353

Contents?: true

Size: 908 Bytes

Versions: 6

Compression:

Stored size: 908 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

    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

6 entries across 6 versions & 1 rubygems

Version Path
vega-0.2.7 lib/vega/lite_chart.rb
vega-0.2.6 lib/vega/lite_chart.rb
vega-0.2.5 lib/vega/lite_chart.rb
vega-0.2.4 lib/vega/lite_chart.rb
vega-0.2.3 lib/vega/lite_chart.rb
vega-0.2.2 lib/vega/lite_chart.rb