Raphael JS 调整画布大小
我正在使用 Raphael JS 编写辩论图。用户可以向图中添加节点。最终图表变得非常大,而画布的大小仍然相同。画布(在raphael js:paper中)位于另一个带有“overflow:scroll;”的div内,所以让我们忽略屏幕空间有没有
一种方法可以在不重新加载页面的情况下调整画布大小(以分配新的X/Y值)? 或者,我可以并行创建第二个更大的画布并复制所有元素吗?有办法吗?
I'm programming a debate-graph with Raphael JS. Users can add nodes to the graph. Eventually the graph gets really big and the canvas is still the same size. the canvas (in raphael js: paper) is inside another div with "overflow: scroll;", so lets ignore screen real estate
Is there a way that I resize the canvas without reloading the page (to assign new X/Y values)?
Alternatively, can I create a second bigger canvas in parallel and copying all the elements over? is there a way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果我理解你的问题,只需调用 setSize() 将画布的大小扩展到您需要的尺寸。我在带有 Overflow:scroll 的 div 中使用了它来获得您描述的效果。
If I understand your question, just call setSize() to expand the size of the canvas to the size needed as you need it. I've used this in a div with overflow:scroll to get the effect you describe.
就我而言,我不想调整大小,我想缩放。
换句话说,向用户展示恒定大小的 div 内不断增长的图表。
所以我需要: setViewBox()
In my case, I didn't want to resize, I wanted to zoom.
In other words, show the user the growing graph inside a constant-sized div.
So I needed: setViewBox()