Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Raphael JS resize Canvas

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?

like image 691
Tony Avatar asked Jun 28 '10 17:06

Tony


2 Answers

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.

like image 200
Mark Avatar answered Nov 05 '22 17:11

Mark


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()

like image 22
The Red Pea Avatar answered Nov 05 '22 17:11

The Red Pea