Skip to content

Commit

Permalink
Ship vega4-extension by default. Fixes #6572
Browse files Browse the repository at this point in the history
  • Loading branch information
domoritz committed Jun 17, 2019
1 parent 79e0399 commit 1b0f9f0
Show file tree
Hide file tree
Showing 15 changed files with 434 additions and 6 deletions.
1 change: 1 addition & 0 deletions buildutils/src/ensure-repo.ts
Expand Up @@ -29,6 +29,7 @@ let UNUSED: Dict<string[]> = {
'@jupyterlab/services': ['node-fetch', 'ws'],
'@jupyterlab/testutils': ['node-fetch', 'identity-obj-proxy'],
'@jupyterlab/test-csvviewer': ['csv-spectrum'],
'@jupyterlab/vega4-extension': ['vega', 'vega-lite'],
'@jupyterlab/vega5-extension': ['vega', 'vega-lite'],
'@jupyterlab/ui-components': ['@blueprintjs/icons']
};
Expand Down
1 change: 1 addition & 0 deletions dev_mode/imports.css
Expand Up @@ -33,4 +33,5 @@
@import url('~@jupyterlab/terminal-extension/style/index.css');
@import url('~@jupyterlab/tooltip-extension/style/index.css');
@import url('~@jupyterlab/vdom-extension/style/index.css');
@import url('~@jupyterlab/vega4-extension/style/index.css');
@import url('~@jupyterlab/vega5-extension/style/index.css');
3 changes: 3 additions & 0 deletions dev_mode/package.json
Expand Up @@ -64,6 +64,7 @@
"@jupyterlab/tooltip": "^1.0.0-alpha.11",
"@jupyterlab/tooltip-extension": "^1.0.0-alpha.11",
"@jupyterlab/vdom-extension": "^1.0.0-alpha.11",
"@jupyterlab/vega4-extension": "^1.0.0-alpha.11",
"@jupyterlab/vega5-extension": "^1.0.0-alpha.11",
"@phosphor/algorithm": "^1.1.2",
"@phosphor/application": "^1.6.0",
Expand Down Expand Up @@ -155,6 +156,7 @@
"@jupyterlab/javascript-extension": "",
"@jupyterlab/json-extension": "",
"@jupyterlab/pdf-extension": "",
"@jupyterlab/vega4-extension": "",
"@jupyterlab/vega5-extension": ""
},
"name": "JupyterLab",
Expand Down Expand Up @@ -249,6 +251,7 @@
"@jupyterlab/theme-light-extension": "../packages/theme-light-extension",
"@jupyterlab/tooltip-extension": "../packages/tooltip-extension",
"@jupyterlab/vdom-extension": "../packages/vdom-extension",
"@jupyterlab/vega4-extension": "../packages/vega4-extension",
"@jupyterlab/vega5-extension": "../packages/vega5-extension"
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/metapackage/src/index.ts
Expand Up @@ -66,4 +66,5 @@ import '@jupyterlab/tooltip';
import '@jupyterlab/tooltip-extension';
import '@jupyterlab/ui-components';
import '@jupyterlab/vdom-extension';
import '@jupyterlab/vega4-extension';
import '@jupyterlab/vega5-extension';
3 changes: 3 additions & 0 deletions packages/metapackage/tsconfig.json
Expand Up @@ -222,6 +222,9 @@
{
"path": "../vdom-extension"
},
{
"path": "../vega4-extension"
},
{
"path": "../vega5-extension"
}
Expand Down
107 changes: 107 additions & 0 deletions packages/vega4-extension/README.md
@@ -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).
56 changes: 56 additions & 0 deletions packages/vega4-extension/package.json
@@ -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
}
}

0 comments on commit 1b0f9f0

Please sign in to comment.