Skip to content

Instantly share code, notes, and snippets.

@JHawk
Last active July 15, 2019 16:45
Show Gist options
  • Save JHawk/9b20383f042853f27c6e720baf4a19db to your computer and use it in GitHub Desktop.
Save JHawk/9b20383f042853f27c6e720baf4a19db to your computer and use it in GitHub Desktop.

Revisions

  1. JHawk revised this gist May 28, 2019. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions index.html
    Original file line number Diff line number Diff line change
    @@ -5,23 +5,23 @@

    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">

    <script src="https://unpkg.com/@jpmorganchase/perspective/build/perspective.js"></script>
    <script src="https://unpkg.com/@jpmorganchase/perspective-viewer/build/perspective.view.js"></script>
    <script src="https://unpkg.com/@jpmorganchase/perspective-viewer-hypergrid/build/hypergrid.plugin.js"></script>
    <script src="https://unpkg.com/@jpmorganchase/perspective-viewer-highcharts/build/highcharts.plugin.js"></script>
    <script src="https://unpkg.com/@finos/perspective/build/perspective.js"></script>
    <script src="https://unpkg.com/@finos/perspective-viewer/build/perspective.view.js"></script>
    <script src="https://unpkg.com/@finos/perspective-viewer-hypergrid/build/hypergrid.plugin.js"></script>
    <script src="https://unpkg.com/@finos/perspective-viewer-d3fc/build/d3fc.plugin.js"></script>

    <script src="example.js"></script>

    <link rel='stylesheet' href="index.css">
    <link rel='stylesheet' href="https://unpkg.com/@jpmorganchase/perspective-viewer/build/material.css" is="custom-style">
    <link rel='stylesheet' href="https://unpkg.com/@finos/perspective-viewer/build/material.css" is="custom-style">

    </head>

    <body>

    <div id="grid">
    <perspective-viewer row-pivots='["Region","State","City"]' sort='[["Profit","desc"]]' columns='["Sales", "Profit"]'></perspective-viewer>
    <perspective-viewer view="sunburst" row-pivots='["Category","Sub-Category","Segment"]' sort='[["Profit","desc"]]' columns='["Sales", "Profit"]'></perspective-viewer>
    <perspective-viewer view="d3_sunburst" row-pivots='["Category","Sub-Category","Segment"]' sort='[["Profit","desc"]]' columns='["Sales", "Profit"]'></perspective-viewer>
    </div>

    </body>
  2. JHawk revised this gist Apr 15, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions index.html
    Original file line number Diff line number Diff line change
    @@ -20,8 +20,8 @@
    <body>

    <div id="grid">
    <perspective-viewer row-pivots='["Sub-Category","Region","Segment"]' sort='[["Profit","desc"]]' columns='["Sales", "Profit"]'></perspective-viewer>
    <perspective-viewer view="sunburst" row-pivots='["Sub-Category","Region","Segment"]' sort='[["Profit","desc"]]' columns='["Sales", "Profit"]'></perspective-viewer>
    <perspective-viewer row-pivots='["Region","State","City"]' sort='[["Profit","desc"]]' columns='["Sales", "Profit"]'></perspective-viewer>
    <perspective-viewer view="sunburst" row-pivots='["Category","Sub-Category","Segment"]' sort='[["Profit","desc"]]' columns='["Sales", "Profit"]'></perspective-viewer>
    </div>

    </body>
  3. JHawk revised this gist Apr 15, 2019. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion .block
    Original file line number Diff line number Diff line change
    @@ -1 +1,2 @@
    license: apache-2.0
    license: apache-2.0
    height: 1200
  4. JHawk revised this gist Apr 15, 2019. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion example.js
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,10 @@
    const ARROW = "https://unpkg.com/@jpmorganchase/perspective-examples/build/superstore.arrow";

    window.addEventListener('WebComponentsReady', function() {

    // Fetch and load arrow data.
    var xhr = new XMLHttpRequest();
    xhr.open('GET', 'superstore.arrow', true);
    xhr.open('GET', ARROW, true);
    xhr.responseType = "arraybuffer"
    xhr.onload = function() {

  5. JHawk revised this gist Apr 15, 2019. 2 changed files with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1 +1 @@
    A demo of linked `<perspective-viewer>`'s using `superstore.arrow`.
    A demo of linked `<perspective-viewer>`s using `superstore.arrow`.
    Binary file removed superstore.arrow
    Binary file not shown.
  6. JHawk revised this gist Apr 15, 2019. 1 changed file with 0 additions and 0 deletions.
    Binary file added superstore.arrow
    Binary file not shown.
  7. JHawk revised this gist Apr 15, 2019. 4 changed files with 73 additions and 7 deletions.
    1 change: 1 addition & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    A demo of linked `<perspective-viewer>`'s using `superstore.arrow`.
    29 changes: 29 additions & 0 deletions example.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    window.addEventListener('WebComponentsReady', function() {

    // Fetch and load arrow data.
    var xhr = new XMLHttpRequest();
    xhr.open('GET', 'superstore.arrow', true);
    xhr.responseType = "arraybuffer"
    xhr.onload = function() {

    // Get `<perspective-viewer>`s from the DOM.
    var el1 = document.getElementsByTagName('perspective-viewer')[0];
    var el2 = document.getElementsByTagName('perspective-viewer')[1];

    // Create a `table()` using the arrow response.
    var table = perspective.shared_worker().table(xhr.response);

    // Load the table in each of the `<perspective-viewer>`s DOM reference.
    el1.load(table);
    el2.load(table);

    // Add an event listener to the first `<perspective-viewer>`.
    el1.addEventListener("perspective-click", e => {

    // Update the second `<perspective-viewer>`, filtering to the row
    // clicked on in the first `<perspective-viewer>`.
    el2.restore(e.detail.config)
    });
    }
    xhr.send(null);
    });
    21 changes: 14 additions & 7 deletions index.css
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,14 @@
    perspective-viewer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    }
    #grid {
    display: flex;
    max-width: 600px;
    max-height: 1200px;
    margin: auto;
    flex-direction: column;
    }

    #grid perspective-viewer {
    height: 600px;
    width: 600px;
    flex: 1;
    display: block;
    }
    29 changes: 29 additions & 0 deletions index.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    <!DOCTYPE html>
    <html>

    <head>

    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">

    <script src="https://unpkg.com/@jpmorganchase/perspective/build/perspective.js"></script>
    <script src="https://unpkg.com/@jpmorganchase/perspective-viewer/build/perspective.view.js"></script>
    <script src="https://unpkg.com/@jpmorganchase/perspective-viewer-hypergrid/build/hypergrid.plugin.js"></script>
    <script src="https://unpkg.com/@jpmorganchase/perspective-viewer-highcharts/build/highcharts.plugin.js"></script>

    <script src="example.js"></script>

    <link rel='stylesheet' href="index.css">
    <link rel='stylesheet' href="https://unpkg.com/@jpmorganchase/perspective-viewer/build/material.css" is="custom-style">

    </head>

    <body>

    <div id="grid">
    <perspective-viewer row-pivots='["Sub-Category","Region","Segment"]' sort='[["Profit","desc"]]' columns='["Sales", "Profit"]'></perspective-viewer>
    <perspective-viewer view="sunburst" row-pivots='["Sub-Category","Region","Segment"]' sort='[["Profit","desc"]]' columns='["Sales", "Profit"]'></perspective-viewer>
    </div>

    </body>

    </html>
  8. JHawk created this gist Apr 15, 2019.
    1 change: 1 addition & 0 deletions .block
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    license: apache-2.0
    7 changes: 7 additions & 0 deletions index.css
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    perspective-viewer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    }