This repository has been archived by the owner on May 3, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
360 additions
and
483 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
default_context: | ||
author_name: "Grant Nestor" | ||
author_email: "[email protected]" | ||
mime_type: "application/vnd.vega.v2+json" | ||
file_extension: "vg" | ||
mime_short_name: "Vega" | ||
extension_name: "jupyterlab_vega" |
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 |
---|---|---|
@@ -1,5 +1,15 @@ | ||
jupyterlab_vega/static/ | ||
jupyterlab_vega/__pycache__/ | ||
jupyterlab_vega.egg-info | ||
node_modules/ | ||
labextension/lib/ | ||
nbextension/lib/ | ||
nbextension/embed/ | ||
*/node_modules/ | ||
npm-debug.log | ||
*.egg-info/ | ||
build/ | ||
dist/ | ||
|
||
# Compiled javascript | ||
jupyterlab_vega/__pycache__/ | ||
jupyterlab_vega/static/ | ||
|
||
# OS X | ||
.DS_Store |
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 |
---|---|---|
@@ -1,6 +1,3 @@ | ||
.Vega { | ||
|
||
} | ||
.vega-actions { | ||
display: none; | ||
} |
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 |
---|---|---|
@@ -1,54 +1,14 @@ | ||
import React from 'react'; | ||
import vegaEmbed from 'vega-embed'; | ||
import './index.css'; | ||
|
||
const DEFAULT_WIDTH = 500; | ||
const DEFAULT_HEIGHT = DEFAULT_WIDTH / 1.5; | ||
|
||
export default class Vega extends React.Component { | ||
|
||
static defaultProps = { | ||
renderedCallback: () => ({}), | ||
embedMode: 'vega-lite' | ||
}; | ||
|
||
componentDidMount() { | ||
this.embed( | ||
this.el, | ||
this.props.data, | ||
this.props.embedMode, | ||
this.props.renderedCallback | ||
); | ||
} | ||
|
||
shouldComponentUpdate(nextProps) { | ||
return this.props.data !== nextProps.data; | ||
} | ||
|
||
componentDidUpdate() { | ||
this.embed( | ||
this.el, | ||
this.props.data, | ||
this.props.embedMode, | ||
this.props.renderedCallback | ||
); | ||
} | ||
export default class VegaComponent extends React.Component { | ||
|
||
render() { | ||
return <div ref={el => this.el = el} />; | ||
return ( | ||
<div className="Vega"> | ||
{JSON.stringify(this.props.data)} | ||
</div> | ||
); | ||
} | ||
|
||
embed = (el, spec, mode, cb) => { | ||
const embedSpec = { mode, spec }; | ||
const width = DEFAULT_WIDTH; | ||
const height = DEFAULT_HEIGHT; | ||
if (mode === 'vega-lite') { | ||
embedSpec.spec.config = { | ||
...embedSpec.spec.config, | ||
cell: { width, height } | ||
}; | ||
} | ||
vegaEmbed(el, embedSpec, cb); | ||
} | ||
|
||
|
||
} |
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 |
---|---|---|
|
@@ -13,10 +13,6 @@ | |
"author": "Grant Nestor <[email protected]>", | ||
"license": "ISC", | ||
"dependencies": { | ||
"d3": "3.5.17", | ||
"react": "^15.3.2", | ||
"vega": "^2.6.1", | ||
"vega-embed": "^2.2.0", | ||
"vega-lite": "^1.1.3" | ||
"react": "^15.3.2" | ||
} | ||
} |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"private": true, | ||
"name": "jupyterlab_vega_labextension", | ||
"version": "0.16.0", | ||
"version": "0.17.0", | ||
"description": "A JupyterLab extension for rendering Vega", | ||
"author": "Grant Nestor <[email protected]>", | ||
"main": "lib/plugin.js", | ||
|
@@ -12,7 +12,7 @@ | |
], | ||
"scripts": { | ||
"build": "node build_extension.js", | ||
"watch": "watch \"npm run build\" src ../component --wait 10 --ignoreDotFiles", | ||
"watch": "watch \"npm install\" src ../component --wait 10 --ignoreDotFiles", | ||
"preinstall": "npm install ../component", | ||
"prepublish": "npm run build", | ||
"extension:install": "jupyter labextension install --symlink --py --sys-prefix jupyterlab_vega", | ||
|
@@ -21,20 +21,19 @@ | |
"extension:disable": "jupyter labextension disable --py --sys-prefix jupyterlab_vega" | ||
}, | ||
"dependencies": { | ||
"jupyterlab": "^0.16.0", | ||
"phosphor": "^0.7.0", | ||
"jupyterlab": "^0.17.0", | ||
"@phosphor/algorithm": "^0.1.0", | ||
"@phosphor/widgets": "^0.1.3", | ||
"react": "^15.3.2", | ||
"react-dom": "^15.3.2" | ||
}, | ||
"devDependencies": { | ||
"@jupyterlab/extension-builder": ">=0.10.0", | ||
"@jupyterlab/services": ">=0.25.0", | ||
"babel-core": "^6.18.2", | ||
"babel-loader": "^6.2.7", | ||
"babel-preset-latest": "^6.16.0", | ||
"babel-preset-react": "^6.16.0", | ||
"babel-preset-stage-0": "^6.16.0", | ||
"rimraf": "^2.5.4", | ||
"watch": "^1.0.1" | ||
} | ||
} |
Oops, something went wrong.