-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
3,951 additions
and
0 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,2 @@ | ||
node_modules | ||
dist |
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 @@ | ||
v16.19.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 @@ | ||
v16.19.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,5 @@ | ||
// A dependency graph that contains any wasm must all be imported | ||
// asynchronously. This `bootstrap.js` file does the single async import, so | ||
// that no one else needs to worry about it again. | ||
import("./index.js") | ||
.catch(e => console.error("Error importing `index.js`:", e)); |
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,11 @@ | ||
<!doctype html> | ||
<html> | ||
<body> | ||
<div id="first"></div> | ||
<noscript | ||
>This page contains webassembly and javascript content, please | ||
enable javascript in your browser.</noscript | ||
> | ||
<script src="./index.js"></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,52 @@ | ||
import { Bruc } from "bruc"; | ||
|
||
const spec = `{ | ||
"dimensions": { | ||
"width": 500, | ||
"height": 500 | ||
}, | ||
"data": [ | ||
{ | ||
"name": "primary", | ||
"values": [] | ||
} | ||
], | ||
"visual": { | ||
"shapes": [ | ||
{ | ||
"from": "primary", | ||
"type": "pie", | ||
"properties": { | ||
"value": { "field": "y" } | ||
} | ||
} | ||
] | ||
} | ||
}`; | ||
|
||
const bruc = Bruc.build(spec); | ||
|
||
await bruc.renderAsSvg("#first"); | ||
|
||
while (true) { | ||
const data = randomData(); | ||
await bruc.setData("primary", data); | ||
|
||
await delay(1000); | ||
} | ||
|
||
function randomData() { | ||
const values = []; | ||
for (let i = 0; i <= randomValue(200); i++) { | ||
values.push({ x: i, y: randomValue(50) }); | ||
} | ||
return values; | ||
} | ||
|
||
function randomValue(max) { | ||
return Math.floor(Math.random() * max); | ||
} | ||
|
||
function delay(time) { | ||
return new Promise((resolve) => setTimeout(resolve, time)); | ||
} |
Oops, something went wrong.