Skip to content

support of "application/vnd.vegalite.v2+json" #127

@cnliao

Description

@cnliao

The latest Jupyterlab comes with vegalite included, so I imagine that this should work:

spec = raw"""
{
  "$schema": "https://vega.github.io/schema/vega-lite/v2.json",
  "description": "A simple bar chart with embedded data.",
  "data": {
    "values": [
      {"a": "A","b": 28}, {"a": "B","b": 55}, {"a": "C","b": 43},
      {"a": "D","b": 91}, {"a": "E","b": 81}, {"a": "F","b": 53},
      {"a": "G","b": 19}, {"a": "H","b": 87}, {"a": "I","b": 52}
    ]
  },
  "mark": "bar",
  "encoding": {
    "x": {"field": "a", "type": "ordinal"},
    "y": {"field": "b", "type": "quantitative"}
  }
}
"""
struct A
    s::String
end
function Base.show(io::IO, m::MIME"application/vnd.vegalite.v2+json", x::A)
    print(io, x.s)
end
display("application/vnd.vegalite.v2+json", A(spec)) # or simply `A(spec)`

So vegalite can work in jupyterlab even without (the excellent) VegaLite.jl.
But currently the above code snippet gives a "Javascript Error: undefined" error.
Any thought on how to fix this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions