Example of how to set and use track ids in TnT Board.
Last active
January 12, 2016 16:21
-
-
Save emepyc/3a7983dd0fee076384de to your computer and use it in GitHub Desktop.
Track Ids
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 ids = function (div) { | |
var board = tnt.board().from(20).to(500).max(500).width(950); | |
// Reload button | |
var reload = d3.select(div) | |
.append("button") | |
.text("Show ids (in console)") | |
.style("margin", "10px") | |
.on("click", function () { | |
var tracks = board.tracks(); | |
for (var i=0; i<tracks.length; i++) { | |
console.log("ID " + tracks[i].id()); | |
} | |
var pins_track = board.find_track("pins"); | |
console.log("Pins track: "); | |
console.log(pins_track); | |
}); | |
// Axis track | |
var axis_track = tnt.board.track() | |
.height(0) | |
.color("white") | |
.display(tnt.board.track.feature.axis() | |
.orientation("top") | |
); | |
// Pin track | |
var pin_track = tnt.board.track() | |
.id ("pins") | |
.height(60) | |
.color("white") | |
.display(tnt.board.track.feature.pin() | |
.domain([0.3, 1.2]) | |
.color("red") | |
) | |
.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(); | |
}; |
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="ids.js"></script> | |
</head> | |
<body> | |
<div id="mydiv"></div> | |
<script> | |
ids(document.getElementById("mydiv")); | |
</script> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment