-
Notifications
You must be signed in to change notification settings - Fork 7
/
example-sdr-hover.html
60 lines (49 loc) · 1.42 KB
/
example-sdr-hover.html
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
<title>2D SDR Drawing</title>
<style>
body { margin: 10px; }
svg {
border: solid 1px orange;
}
</style>
</head>
<body>
<svg id="sdrHover"></svg>
<br/>
Hovering over: <span class="hoverDisplay"></span>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://d3js.org/d3.v5.min.js"></script>
<script src="dist/cell-viz-2d-1.4.6.min.js"></script>
<script>
$(function() {
let $hoverDisplay = $('.hoverDisplay')
function renderDisplay() {
let sdr = []
for (let i = 0; i < 400; i++) {
let r = Math.random()
if (r < .3) sdr.push(null)
if (r < .6) sdr.push(0)
else sdr.push(Math.random())
}
new SdrDrawing(sdr, 'sdrHover').draw({
width: 560,
height: 560,
gradientFill: true,
threshold: 0.5,
}).onCell('mouseover', function(data, i) {
$hoverDisplay.html(`cell ${i} at ${data}`)
}).onConnection('mouseover', function(data) {
$hoverDisplay.html(`connection ${data.permanence} at ${data.index}`)
})
}
renderDisplay()
$('input').on('input', () => {
renderDisplay()
})
});
</script>
</body>
</html>