我正在使用cytoscape.js来显示一棵树。当树有多个节点时,它可以很好地工作,但是当我的树只包含一个节点时,它会在可见区域之外呈现。 我可以缩小它,它会出现在我容器的右下边缘。
初始化如下:
call: ->
$ loadCy = =>
options =
layout: {
name: 'breadthfirst'
# maximalAdjustments: 2
roots: @_findRootNode()
padding: 10
},
showOverlay: true
boxSelectionEnabled: false
minZoom: 0.5
maxZoom: 1.5
style: cytoscape.stylesheet().selector("node").css(
content: "data(name)"
"font-family": "helvetica"
"font-size": 12
"text-outline-width": 1
"text-outline-color": "#888"
"text-valign": "center"
color: "#fff"
width: "mapData(weight, 30, 80, 20, 50)"
height: "mapData(height, 0, 200, 10, 45)"
"border-color": "#fff"
).selector(":selected").css(
"background-color": "#000"
"line-color": "#000"
"target-arrow-color": "#000"
"text-outline-color": "#000"
).selector("edge").css(
width: 2
"target-arrow-shape": "triangle"
)
elements:
nodes: @_nodesArray()
edges: @_edgesArray()
ready: ->
cy = this
return
$( @canvas ).cytoscape options
return
有没有人有同样的问题? 谢谢!