UNPKG

tnt.board

Version:

TnT track-based board display

54 lines (41 loc) 1.31 kB
var apijs = require ("tnt.api"); var iterator = require("tnt.utils").iterator; var track = function () { "use strict"; var display; var conf = { color : d3.rgb('#CCCCCC'), height : 250, // data is the object (normally a tnt.track.data object) used to retrieve and update data for the track data : track.data.empty(), // display : undefined, label : "", id : track.id() }; // The returned object / closure var t = {}; // API var api = apijs (t) .getset (conf); // TODO: This means that height should be defined before display // we shouldn't rely on this t.display = function (new_plotter) { if (!arguments.length) { return display; } display = new_plotter; if (typeof (display) === 'function') { display.layout && display.layout().height(conf.height); } else { for (var key in display) { if (display.hasOwnProperty(key)) { display[key].layout && display[key].layout().height(conf.height); } } } return this; }; return t; }; track.id = iterator(1); module.exports = exports = track;