Skip to content

Instantly share code, notes, and snippets.

@texodus
Created March 25, 2022 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save texodus/54857753e5642799240ff1ecd161175a to your computer and use it in GitHub Desktop.
Save texodus/54857753e5642799240ff1ecd161175a to your computer and use it in GitHub Desktop.
Perspective / Master-Detail
<!--
Copyright (c) 2017, the Perspective Authors.
This file is part of the Perspective library, distributed under the terms of
the Apache License 2.0. The full license can be found in the LICENSE file.
-->
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no"/>
<script type="module" src="https://cdn.jsdelivr.net/npm/@finos/perspective@latest/dist/cdn/perspective.js"></script>
<script type="module" src="https://cdn.jsdelivr.net/npm/@finos/perspective-viewer@latest/dist/cdn/perspective-viewer.js"></script>
<script type="module" src="https://cdn.jsdelivr.net/npm/@finos/perspective-viewer-datagrid@latest/dist/cdn/perspective-viewer-datagrid.js"></script>
<script type="module" src="https://cdn.jsdelivr.net/npm/@finos/perspective-viewer-d3fc@latest/dist/cdn/perspective-viewer-d3fc.js"></script>
<link rel="stylesheet" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@finos/perspective-viewer/dist/css/themes.css" />
<script type="module">
import {worker} from "https://cdn.jsdelivr.net/npm/@finos/perspective@latest/dist/cdn/perspective.js";
const WORKER = worker();
const REQ = fetch("https://cdn.jsdelivr.net/npm/superstore-arrow/superstore.arrow");
async function load() {
const resp = await REQ;
const arrow = await resp.arrayBuffer();
const [el1, el2] = document.getElementsByTagName("perspective-viewer");
const table = WORKER.table(arrow);
el1.load(table);
el1.restore({group_by: ["State"], columns: ["Sales"]});
el2.load(table);
el1.addEventListener("perspective-select", event => {
el2.restore(event.detail.config);
});
}
load();
</script>
<style>
body {
display: flex;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
perspective-viewer {
flex: 1;
align-items: stretch;
justify-content: stretch;
}
</style>
</head>
<body>
<perspective-viewer selectable></perspective-viewer>
<perspective-viewer></perspective-viewer>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment