forked from jupyterlab/jupyterlab
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ship vega4-extension by default. Fixes jupyterlab#6572
- Loading branch information
Showing
16 changed files
with
435 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
# vega4-extension | ||
|
||
A JupyterLab extension for rendering [Vega](https://vega.github.io/vega) 4 and [Vega-Lite](https://vega.github.io/vega-lite) 2. | ||
|
||
![demo](http://g.recordit.co/USoTkuCOfR.gif) | ||
|
||
## Prerequisites | ||
|
||
- JupyterLab ^0.27.0 | ||
|
||
## Usage | ||
|
||
To render Vega-Lite output in IPython: | ||
|
||
```python | ||
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](https://github.com/altair-viz/altair): | ||
|
||
```python | ||
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: | ||
|
||
```python | ||
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: | ||
|
||
```python | ||
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](https://github.com/jupyterlab/jupyterlab/blob/master/CONTRIBUTING.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{ | ||
"name": "@jupyterlab/vega4-extension", | ||
"version": "1.0.0-alpha.11", | ||
"description": "JupyterLab - Vega 4 and Vega-Lite 2 Mime Renderer Extension", | ||
"homepage": "https://github.com/jupyterlab/jupyterlab", | ||
"bugs": { | ||
"url": "https://github.com/jupyterlab/jupyterlab/issues" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/jupyterlab/jupyterlab.git" | ||
}, | ||
"license": "BSD-3-Clause", | ||
"author": "Project Jupyter", | ||
"files": [ | ||
"lib/*.d.ts", | ||
"lib/*.js", | ||
"style/*.*" | ||
], | ||
"sideEffects": [ | ||
"style/**/*" | ||
], | ||
"main": "lib/index.js", | ||
"types": "lib/index.d.ts", | ||
"style": "style/index.css", | ||
"directories": { | ||
"lib": "lib/" | ||
}, | ||
"scripts": { | ||
"build": "tsc -b", | ||
"clean": "rimraf lib", | ||
"docs": "typedoc --options tdoptions.json --theme ../../typedoc-theme src", | ||
"prepublishOnly": "npm run build", | ||
"watch": "tsc -b --watch" | ||
}, | ||
"dependencies": { | ||
"@jupyterlab/rendermime-interfaces": "^1.3.0-alpha.11", | ||
"@phosphor/coreutils": "^1.3.0", | ||
"@phosphor/widgets": "^1.7.1", | ||
"vega": "^4.4.0", | ||
"vega-embed": "^4.2.0", | ||
"vega-lite": "^2.6.0" | ||
}, | ||
"devDependencies": { | ||
"@types/webpack-env": "^1.13.9", | ||
"rimraf": "~2.6.2", | ||
"typedoc": "^0.14.2", | ||
"typescript": "~3.5.1" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"jupyterlab": { | ||
"mimeExtension": true | ||
} | ||
} |
Oops, something went wrong.