Skip to content

Commit

Permalink
working
Browse files Browse the repository at this point in the history
  • Loading branch information
tomjakubowski committed Nov 6, 2023
1 parent c6a0093 commit 081bd64
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions python/perspective/perspective/templates/bruce.html.jinja
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
<!-- FIXME: should only include viewer 1x per export -->
<script type="module" src="https://cdn.jsdelivr.net/npm/@finos/perspective/dist/cdn/perspective.js"></script>
<script type="module"
src="https://cdn.jsdelivr.net/npm/@finos/perspective-viewer/dist/cdn/perspective-viewer.js"></script>
<script type="module"
src="https://cdn.jsdelivr.net/npm/@finos/perspective-viewer-datagrid/dist/cdn/perspective-viewer-datagrid.js"></script>
<script type="module"
src="https://cdn.jsdelivr.net/npm/@finos/perspective-viewer-d3fc/dist/cdn/perspective-viewer-d3fc.js"></script> -->
src="https://cdn.jsdelivr.net/npm/@finos/perspective-viewer-d3fc/dist/cdn/perspective-viewer-d3fc.js"></script>

<link rel="stylesheet" crossorigin="anonymous"
href="https://cdn.jsdelivr.net/npm/@finos/perspective-viewer/dist/css/pro.css" />

<div class="perspective-envelope">
<div class="perspective-envelope" id="perspective-envelope-{{viewer_id}}">
<script type="application/vnd.apache.arrow.file">
{{ b64_data }}
{{ b64_data }}
</script>
<perspective-viewer style="height: 690px;"></perspective-viewer>
<script type="module">
Expand All @@ -23,16 +22,19 @@
}
import * as perspective from "https://cdn.jsdelivr.net/npm/@finos/perspective/dist/cdn/perspective.js";
const viewerId = {{ viewer_id | tojson }};
const currentScript = document.scripts[document.scripts.length - 1];
const envelope = currentScript.parentElement;
const envelope = document.getElementById(`perspective-envelope-${viewerId}`);
const dataScript = envelope.querySelector('script[type="application/vnd.apache.arrow.file"]');;
if (!dataScript)
throw new Error('tape missing');
throw new Error('data script missing for viewer', viewerId);
const data = base64ToBytes(dataScript.textContent);
const viewerAttrs = {{ viewer_attrs | tojson }};
// Create a new worker, then a new table promise on that worker.
const table = await perspective.worker().table(data.buffer);
const viewer = envelope.querySelector('perspective-viewer');
viewer.load(table);
viewer.restore(viewerAttrs);
</script>
</div>

0 comments on commit 081bd64

Please sign in to comment.