Published
Edited
May 10, 2019
6 stars
Insert cell
Insert cell
viewer = html `
<div style="height:${width*.6}px">
<perspective-viewer
view="treemap"
row-pivots='["Sub-Category","Region","Segment"]'
sort='[["Profit","desc"]]'
columns='["Sales", "Profit"]'>
</perspective-viewer>
</div>
`
Insert cell
viewerLoad = window.addEventListener('WebComponentsReady', function() {
console.log('WebComponentsReady: loading plugins...');
const hyperGrid = loadPerspectiveViewerPlugins();
const viewer = document.getElementsByTagName('perspective-viewer')[0];
console.log('WebComponentsReady: loading data:', dataUrl);
loadData(dataUrl).then(buffer => {
console.log('Loading view data...');
viewer.load(buffer);
viewer.toggleConfig();
});
})
Insert cell
async function loadPerspectiveViewerPlugins() {
console.log('loadPerspectiveViewerPlugins: loading plugins...');
const hyperGrid = await require('@finos/perspective-viewer-hypergrid@0.3.0-rc.1/build/hypergrid.plugin.js');
const highCharts = await require('@finos/perspective-viewer-highcharts@0.3.0-rc.1/build/highcharts.plugin.js');
return hyperGrid;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
dataSample = md`${getMarkdown(every2KRecord, fields, ['Order Date', 'Ship Date'])}` // date fields
Insert cell
Insert cell
Insert cell
arrow = require('apache-arrow@0.3.1')
Insert cell
perspective = require('@finos/perspective@0.3.0-rc.1/build/perspective.js')
Insert cell
perspectiveViewer = require('@finos/perspective-viewer@0.3.0-rc.1/build/perspective.view.js')
Insert cell
Insert cell
viewerStyle = html`
<link rel='stylesheet' href="https://unpkg.com/@finos/perspective-viewer@0.3.0-rc.1/build/material.css" is="custom-style" />
<style>
perspective-viewer {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
</style>
`
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more