-
Notifications
You must be signed in to change notification settings - Fork 31
/
viz.js
43 lines (34 loc) · 898 Bytes
/
viz.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
35
36
37
38
39
40
41
42
'use strict'
import './viz.less'
import Viz from '../viz/main'
import data from './test-data.json'
function debounce(fn, time) {
let last = null
let tout = null
return function check() {
if (last === null || time < Date.now() - last) {
clearTimeout(tout)
last = Date.now()
fn.call(this, arguments)
} else {
tout = setTimeout(check, time)
}
}
}
function main() {
let tracer = window.__rxvision_tracer
if (!tracer) {
return console.warn('RxVision tracer not found')
}
let div = document.querySelector('[data-rxvision]')
if (!div) {
div = document.createElement('div')
document.body.appendChild(div)
}
let viz = new Viz(div)
// viz.process({streams: tracer.streams, groups: tracer.agroups})
tracer.config.onValue = debounce(() => {
viz.process({streams: tracer.streams, groups: tracer.agroups})
}, 100)
}
main()