Skip to content

Instantly share code, notes, and snippets.

@jorgeatgu
Created October 19, 2021 11:04
Show Gist options
  • Save jorgeatgu/b289d0ad98f9d3271d467db91b995714 to your computer and use it in GitHub Desktop.
Save jorgeatgu/b289d0ad98f9d3271d467db91b995714 to your computer and use it in GitHub Desktop.
Perspective datetime
license: mit
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<link rel='stylesheet' href="https://unpkg.com/@finos/perspective-workspace/dist/umd/material.dark.css">
<script src="https://unpkg.com/@finos/perspective-workspace/dist/umd/perspective-workspace.js"></script>
<script src="https://unpkg.com/@finos/perspective-viewer-datagrid"></script>
<script src="https://unpkg.com/@finos/perspective-viewer-d3fc"></script>
<script src="https://unpkg.com/@finos/perspective/dist/umd/perspective.js"></script>
<script src="index.js"></script>
<link rel='stylesheet' href="styles.css">
</head>
<body>
<perspective-viewer></perspective-viewer>
</body>
</html>
window.addEventListener("load", async () => {
const elem = document.getElementsByTagName("perspective-viewer")[0];
const schema = {
x: "integer",
y: "string",
z: "datetime"
}
const worker = perspective.worker();
const table = await worker.table(schema);
elem.load(table)
table.update([
{ x: 1, y: "a", z: "2000-01-05 14:24:58.000000"},
{ x: 2, y: "b", z: "2007-05-16 10:12:32.000000"},
{ x: 3, y: "c", z: "2009-11-18 18:12:45.000000"},
{ x: 4, y: "d", z: "2010-05-26 13:29:53.000000" },
{ x: 1, y: "a", z: "2000-01-05 14:24:58"},
{ x: 2, y: "b", z: "2007-05-16 10:12:32"},
{ x: 3, y: "c", z: "2009-11-18 18:12:45"},
{ x: 4, y: "d", z: "2010-05-26 13:29:53" }
]);
});
perspective-viewer {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment