Skip to content

Commit

Permalink
support loading schema
Browse files Browse the repository at this point in the history
  • Loading branch information
timkpaine committed May 14, 2018
1 parent b03f319 commit 9ca224f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/perspective-jupyterlab/src/ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const PSP_CONTAINER_CLASS = 'jp-PSPContainer';

interface PerspectiveSpec {
data: string,
schema: string,
layout: string,
config: string;
}
Expand All @@ -45,7 +46,9 @@ export class RenderedPSP extends Widget implements IRenderMime.IRenderer {
if (this._loaded) return;
let psp = (<any>(this.node.querySelector('perspective-viewer')));

let schema = JSON.parse(this._schema);
let layout = JSON.parse(this._lyt);

for(let key in layout){
if(layout[key]){
if(key !== 'view'){
Expand All @@ -56,8 +59,12 @@ export class RenderedPSP extends Widget implements IRenderMime.IRenderer {
}
}

if (schema) {
psp.load(schema);
}

if (this._datatype === 'static') {
psp.load(this._data);
psp.update(this._data);
} else if (this._datatype === 'ws' || this._datatype === 'wss') {
let config = JSON.parse(this._config);
let send = config.send || '';
Expand Down Expand Up @@ -111,8 +118,9 @@ export class RenderedPSP extends Widget implements IRenderMime.IRenderer {
}

renderModel(model: IRenderMime.IMimeModel): Promise<void> {
const {data, layout, config} = model.data[MIME_TYPE] as any | PerspectiveSpec;
const {data, schema, layout, config} = model.data[MIME_TYPE] as any | PerspectiveSpec;
this._lyt = layout;
this._schema = schema;

try {
this._data = JSON.parse(data) as object;
Expand Down Expand Up @@ -156,6 +164,7 @@ export class RenderedPSP extends Widget implements IRenderMime.IRenderer {
private _data: object;
private _datatype: string;
private _datasrc: string;
private _schema: string;
private _lyt: string; // not widget layout
private _config: string;
private _loaded: boolean;
Expand Down

0 comments on commit 9ca224f

Please sign in to comment.