-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #267 from jpmorganchase/new-examples
New examples
- Loading branch information
Showing
8 changed files
with
237 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
An example of Remote Perspective as a CLI tool. Reads from STDIN, loads a | ||
Perspective instance via node.js, and opens a web browser to display the data. | ||
Can infer CSV, JSON and Apache Arrow data. Example: | ||
|
||
```bash | ||
cat example.arrow | perspective-cli | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/****************************************************************************** | ||
* | ||
* 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. | ||
* | ||
*/ | ||
|
||
perspective-viewer { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
right: 0; | ||
bottom: 0; | ||
} | ||
|
||
@media (max-width: 600px) { | ||
html { | ||
overflow: hidden; | ||
} | ||
|
||
body { | ||
position: fixed; | ||
height: 100%; | ||
width: 100%; | ||
margin: 0; | ||
overflow: hidden; | ||
touch-action: none; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<!-- | ||
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 src="perspective.view.js"></script> | ||
<script src="hypergrid.plugin.js"></script> | ||
<script src="highcharts.plugin.js"></script> | ||
|
||
<script src="perspective.js"></script> | ||
|
||
<link rel='stylesheet' href="index.css"> | ||
<link rel='stylesheet' href="material.css"> | ||
|
||
</head> | ||
|
||
<body> | ||
|
||
<perspective-viewer | ||
id="view1"> | ||
|
||
</perspective-viewer> | ||
|
||
<script> | ||
window.addEventListener('WebComponentsReady', function() { | ||
var elem = document.getElementById('view1'); | ||
var worker = perspective.worker(window.location.origin.replace('http', 'ws')); | ||
elem.load(worker.open('data_source_one')); | ||
}); | ||
</script> | ||
|
||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "cli", | ||
"private": true, | ||
"version": "0.2.1", | ||
"description": "An example of Remote Perspective as a CLI tool.", | ||
"scripts": { | ||
"start": "node server.js" | ||
}, | ||
"keywords": [], | ||
"license": "Apache-2.0", | ||
"bin": { | ||
"perspective-cli": "server.js" | ||
}, | ||
"dependencies": { | ||
"@jpmorganchase/perspective": "^0.2.1", | ||
"@jpmorganchase/perspective-viewer": "^0.2.1", | ||
"@jpmorganchase/perspective-viewer-highcharts": "^0.2.1", | ||
"@jpmorganchase/perspective-viewer-hypergrid": "^0.2.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/****************************************************************************** | ||
* | ||
* 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. | ||
* | ||
*/ | ||
|
||
const {WebSocketHost} = require("@jpmorganchase/perspective/build/perspective.node.js"); | ||
const exec = require("child_process").exec; | ||
|
||
const OPEN = ` | ||
if which xdg-open > /dev/null | ||
then | ||
xdg-open http://localhost:8080/ | ||
elif which gnome-open > /dev/null | ||
then | ||
gnome-open http://localhost:8080/ | ||
elif which open > /dev/null | ||
then | ||
open http://localhost:8080/ | ||
fi`; | ||
|
||
function execute(command, callback) { | ||
exec(command, function(error, stdout) { | ||
if (callback) { | ||
callback(stdout); | ||
} | ||
}); | ||
} | ||
const host = new WebSocketHost({assets: [__dirname]}); | ||
|
||
let ret = [], | ||
len = 0; | ||
|
||
process.stdin | ||
.on("readable", function() { | ||
let chunk; | ||
while ((chunk = process.stdin.read())) { | ||
ret.push(new Buffer(chunk)); | ||
len += chunk.length; | ||
} | ||
}) | ||
.on("end", function() { | ||
const buf = Buffer.concat(ret, len); | ||
if (buf.slice(0, 6).toString() === "ARROW1") { | ||
host.open("data_source_one", buf.buffer); | ||
console.log("Loaded Arrow"); | ||
} else { | ||
let text = buf.toString(); | ||
try { | ||
let json = JSON.parse(text); | ||
host.open("data_source_one", json); | ||
console.log("Loaded JSON"); | ||
} catch (e) { | ||
host.open("data_source_one", text); | ||
console.log("Loaded CSV"); | ||
} | ||
} | ||
execute(OPEN, console.log); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters