From NPM

@jpmorganchase/perspective
The main library, as both a browser ES6 and Node.js module. Provides an
asm.js, WebAssembly, WebWorker (browser) and Process (node.js)
implementation.

@jpmorganchase/perspective-viewer
A configuration and visualization (via plugins) UI, bundled as a Web Component.

@jpmorganchase/perspective-viewer-hypergrid
A perspective-viewer plugin for Hypergrid.

@jpmorganchase/perspective-viewer-highcharts
A perspective-viewer plugin for HighCharts.

@jpmorganchase/perspective-examples
All perspective modules, bundled with their dependencies as standalone
Javascript files.

From source

Perspective is organized as a monorepo,
and uses lerna to manage dependencies. @jpmorganchase/perspective depends on an additional enviornment dependency, emscripten, to compile the core C++ engine. You’ll need to install the emscripten SDK, then activate and export the latest emsdk environment via emsdk_env.sh:

source emsdk/emsdk_env.sh

Once installed, you can build perspective via:

npm install
./node_modules/.bin/lerna run start --stream

If everything is successful, you should find a few built example assets in the
packages/perspective-examples/build directory:

OSX specific instructions

You’ll also need Boost and CMake, which can be installed from Homebrew:

brew install cmake
brew install boost

Windows 10 specific instructions

You need to use bash in order to build Perspective packages. To successfully build on Windows 10, enable Windows Subsystem for Linux (WSL) and install the linux distribution
of your choice.

Create symbolic link to easily access Windows directories and projects modified via Windows. This way you can modify any of the Perspective files using your favorite editors on Windows
and build via Linux.

Follow the Linux specific instructions to install Emscripten and all prerequisite tools.

Linux specific instructions

You might need to apply a workaround to correctly link boost libraries as described here.

cp -r /usr/include/boost ./packages/perspective/src/include/

Options

The build script respects a few environment flags:

PSP_DEBUG will run a debug build of the C++ source.

PSP_NO_MINIFY will skip Javascript minification.

Usage

A note on WebAssembly/asm.js in the browser

Whether you use just the perspective engine itself, or the
perspective-viewer web component, your browser will need to
have access to the .asm.js, .js.mem and/or .wasm assets in addition to the
bundled scripts themselves. These can be found in the perspective/build/asmjs
and perspective/build/wasm_async directories of the package; while the root level
perspective/index.js wrapper will automatically determine which runtime to
use based on your browser’s WebAssembly support, you’ll need to make sure to
copy both directories to the same relative directory you plan to host your
site bundle from:

Perspective library

As a library, perspective provides a suite of streaming pivot, aggregate, filter
and sort operations for tabular data. The engine can be instantiated in process,
or in a Web Worker (browser only).

In the browser

Via ES6 module and/or Babel:

importperspectivefrom'perspective';

or

constperspective=require('perspective');

Perspective can also be referenced via the global perspective module name in vanilla
Javascript.

Once imported, you’ll need to instance a perspective engine via the worker()
method. This will create a new WebWorker (browser) or Process (node.js), and
load the appropriate supported WebAssembly or asm.js binary; all calculation
and data accumulation will occur in this separate process.

In Node.js

Usage

The basic data primitive of perspective is the table, which you can
instantiate via the table() method on a worker. Further data can be
supplied to the table via its update() method.

// With data (also works with strings in CSV format)vardata=[{'x':1,'y':'a','z':true},{'x':2,'y':'b','z':false},{'x':3,'y':'c','z':true},{'x':4,'y':'d','z':false}];consttable1=worker.table(data);// With a schemavarschema={x:'integer',y:'string',z:'boolean'};consttable2=worker.table(schema);// Add a new row to each tabletable1.update([{x:5,y:'e',z:true}]);table2.update([{x:5,y:'e',z:true}]);

The table() method also takes an options object, with which you can provide
the name of an index column in the underlying dataset, which will act as a
primary key on the table, replacing updated rows instead of appending them.

// Use the 'x' column as a primary keyconsttable3=worker.table(data,{index:'x'});

In order to query the table, you must then create a view(), an immutable set
of transformations for an associated table(). A view() is created from a
table() via a configuration object, and a view() instance can return data
from queries to its various methods (see the API).

Perspective-viewer web component

As a component, perspective-viewer provides a complete graphical UI for
configuring the perspective library and formatting its output to the
provided visualization plugins.

If you are using babel or another build environment which supports ES6 modules,
you need only import the perspective-viewer libraries somewhere in your
application - these modules export nothing, but rather register the components
for use within your site’s regular HTML: