1.2.0 • Published 4 years ago

@jupyterlab/vega4-extension v1.2.0

Weekly downloads
3,861
License
BSD-3-Clause
Repository
github
Last release
4 years ago

vega4-extension

A JupyterLab extension for rendering Vega 4 and Vega-Lite 2.

demo

Prerequisites

  • JupyterLab ^0.27.0

Usage

To render Vega-Lite output in IPython:

from IPython.display import display

display({
    "application/vnd.vegalite.v2+json": {
        "$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"}
        }
    }
}, raw=True)

Using the altair library:

import altair as alt

cars = alt.load_dataset('cars')

chart = alt.Chart(cars).mark_point().encode(
    x='Horsepower',
    y='Miles_per_Gallon',
    color='Origin',
)

chart

Provide vega-embed options via metadata:

from IPython.display import display

display({
    "application/vnd.vegalite.v2+json": {
        "$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"}
        }
    }
}, metadata={
    "application/vnd.vegalite.v2+json": {
        "embed_options": {
            "actions": False
        }
    }
}, raw=True)

Provide vega-embed options via altair:

import altair as alt

alt.renderers.enable('default', embed_options={'actions': False})

cars = alt.load_dataset('cars')

chart = alt.Chart(cars).mark_point().encode(
    x='Horsepower',
    y='Miles_per_Gallon',
    color='Origin',
)

chart

To render a .vl, .vg, vl.json or .vg.json file, simply open it:

Development

See the JupyterLab Contributor Documentation.

2.0.0-alpha.4

4 years ago

2.0.0-alpha.3

4 years ago

2.0.0-alpha.2

4 years ago

1.2.0

5 years ago

1.2.0-rc.0

5 years ago

1.2.0-alpha.3

5 years ago

1.2.0-alpha.2

5 years ago

1.2.0-alpha.1

5 years ago

2.0.0-alpha.1

5 years ago

2.0.0-alpha.0

5 years ago

1.2.0-alpha.0

5 years ago

1.1.0

5 years ago

1.0.3

5 years ago

1.1.0-rc.0

5 years ago

1.0.2

5 years ago

1.1.0-alpha.2

5 years ago

1.1.0-alpha.1

5 years ago

1.1.0-alpha.0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

1.0.0-rc.1

5 years ago

1.0.0-rc.0

5 years ago

1.0.0-alpha.13

5 years ago

1.0.0-alpha.4

5 years ago

1.0.0-alpha.3

5 years ago

1.0.0-alpha.2

5 years ago

1.0.0-alpha.1

5 years ago

1.0.0-alpha.0

5 years ago

0.18.1

6 years ago

0.18.1-alpha.0

6 years ago

0.17.4

6 years ago

0.17.3

6 years ago

0.17.2

6 years ago

0.17.0

6 years ago

0.16.2

6 years ago

0.16.1

6 years ago

0.16.0-1

6 years ago

0.16.0-0

6 years ago

0.15.2

6 years ago