Labella.js时间轴标签放置工具
Labella.js 是 Twitter 开源的时间轴标签放置工具,可以把标签没有重叠的放在时间轴上。
“标签也可以很美丽”
在线演示:http://twitter.github.io/labella.js/
示例代码:
// idealPos: The most preferred position for each label // width: The width of each label var nodes = [ new labella.Node(1, 50), // idealPos, width new labella.Node(2, 50), new labella.Node(3, 50), new labella.Node(3, 50), new labella.Node(3, 50), ]; var force = new labella.Force() .nodes(nodes) // Listen when the nodes' positions are updated. .on('end', function(){ // The rendering is independent from this library. // User can use canvas, svg or any library to draw the labels. // There is also a built-in helper labella.Renderer for this purpose. See the examples draw(force.nodes()); }) // Run simulation at most 100 rounds. It may end earlier if equillibrium is reached. .start(100);
评论