-
Notifications
You must be signed in to change notification settings - Fork 29
/
index.js
34 lines (29 loc) · 893 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const dscc = require('@google/dscc');
const local = require('./localMessage.js');
// change this to 'true' for local development
// change this to 'false' before deploying
export const LOCAL = true;
// write viz code here
const drawViz = (data) => {
// add a README
if (document.querySelector('div')) {
var oldDiv = document.querySelector('div');
oldDiv.parentNode.removeChild(oldDiv);
}
// append the data to a div
let div = document.createElement('div');
div.innerHTML = `<h2>Community Visualization Codelab</h2>
This is the starter template for the <code>dscc-gen</code> codelab.
<p>
There are currently ${data.tables.DEFAULT.length} rows in the data.
</p>
`;
document.body.appendChild(div);
console.log(data);
};
// renders locally
if (LOCAL) {
drawViz(local.message);
} else {
dscc.subscribeToData(drawViz, {transform: dscc.objectTransform});
}