Example of how to re-start the visualisation in TnT Board.
Last active
January 12, 2016 16:23
-
-
Save emepyc/61a609789fed6d86b84f to your computer and use it in GitHub Desktop.
Visualisation reload
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
<!DOCTYPE html> | |
<head> | |
<link rel="stylesheet" href="http://tntvis.github.io/tnt.board/build/tnt.board.css" type="text/css" /> | |
<style> | |
#mydiv { | |
margin-top: 200px; | |
} | |
</style> | |
<script src="http://d3js.org/d3.v3.min.js"></script> | |
<script src="http://tntvis.github.io/tnt.board/build/tnt.board.min.js"></script> | |
<script src="reload.js"></script> | |
</head> | |
<body> | |
<div id="mydiv"></div> | |
<script> | |
reload(document.getElementById("mydiv")); | |
</script> | |
</body> |
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
var orig = { | |
from: 20, | |
to: 500 | |
}; | |
var reload = function (div) { | |
var board = tnt.board().from(orig.from).to(orig.to); | |
// reload button | |
var reload = d3.select(div) | |
.append("button") | |
.text("reload") | |
.style("margin", "10px") | |
.on("click", function () { | |
board.from(orig.from); | |
board.to(orig.to); | |
board.start(); | |
}); | |
var axis_track = tnt.board.track() | |
.height(0) | |
.color("white") | |
.display(tnt.board.track.feature.axis() | |
.orientation("top") | |
); | |
var pin_track = tnt.board.track() | |
.height(60) | |
.color("white") | |
.display(tnt.board.track.feature.pin() | |
.domain([0.3, 1.2]) | |
.color("red") | |
.on("click", function (d) { | |
console.log(d); | |
}) | |
.on("mouseover", function (d) { | |
console.log("mouseover"); | |
}) | |
) | |
.data(tnt.board.track.data.sync() | |
.retriever (function () { | |
return [ | |
{ | |
pos : 200, | |
val : 0.5, | |
label : "1" | |
}, | |
{ | |
pos : 355, | |
val : 0.8, | |
label : "2" | |
}, | |
{ | |
pos : 100, | |
val : 0.3, | |
label : "3" | |
}, | |
{ | |
pos : 400, | |
val : 1, | |
label : "4" | |
} | |
]; | |
}) | |
); | |
board | |
.add_track(axis_track) | |
.add_track(pin_track); | |
board(div); | |
board.start(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment