我正在研究 gojs 时间线示例(http://gojs.net/latest/samples/timeline.html),这是基于日期的默认功能。我已经向现有节点添加了更多数量的节点,因为它们每个都重叠其他。那么如何在这个布局中设置节点间距。
1 回答
0
在示例的原型代码中,您可以找到可以重写的部分:
var bar = line.findObject("BAR");
var length = 100;
var cellw = 100;
if (bar && numweeks > 0) {
length = bar.actualBounds.width;
cellw = length / numweeks;
// set the size of each cell
bar.gridCellSize = new go.Size(cellw, bar.gridCellSize.height);
// offset to account for starting on a non-first day of the week
bar.gridOrigin = new go.Point(convertDateToX(firstsunday), bar.gridOrigin.y);
}
这里有三个选项(其实是两个,3.只是一个建议):
改变
var
s:var length = /*the length you want the bar to have (you could take the number of cells * the cellw below)*/ var cellw = /*the length you want each cell to have*/
使其可配置:
做类似的事情
TimelineLayout.prototype.setCellW = function(newcellW){ this.cellW = newcellW; }
然后在上面显示的部分中引用它。
- 改用 GridLayout:看看这里是否足以满足您的需求。
于 2015-08-24T11:10:12.803 回答