automatic resize of an SVG

7.221 kali dilihat
Langsung ke pesan pertama yang belum dibaca

Sergiy Nesterko

belum dibaca,
15 Okt 2011, 17.21.4915/10/11
kepadad3-js
Hi everyone,

Hope your d3 projects and other things are moving along well. I have a
general question about d3. Here is a quote of Mike Bostock:

On
the other hand, vector-based graphics offer advantages as well, such
as the ability to scale the graphic up to arbitrary sizes. You can
print SVG to PDF to embed it in other documents, or simply increase
the size of the SVG and the graphic will resize automatically.

Is there a way to easily do this without manually updating (invoking
transitions) for all the elements in your d3-controlled SVG? Plain
resizing of an SVG element in an html page would not work, or would
it? Thank you.

Sergiy

Mike Bostock

belum dibaca,
15 Okt 2011, 18.05.0815/10/11
kepadad3...@googlegroups.com
If you set the viewBox attribute, you can then set the width and
height attributes independently, and the content will be rescaled. You
can also adjust the preserveAspectRatio attribute as desired. For
example, say I have an existing SVG that is 600x600. I can make it
wider:

d3.select("svg")
.attr("viewBox", "0 0 600 600")
.attr("width", "1280")
.attr("preserveAspectRatio", "none");

http://www.w3.org/TR/SVG/coords.html#ViewBoxAttribute

Mike

Chris Viau

belum dibaca,
15 Okt 2011, 18.09.5015/10/11
kepadad3...@googlegroups.com
Look at this example and try resizing your window: http://christopheviau.com/d3_tutorial/d3_examples/ . Maybe it can help.

Ian Johnson

belum dibaca,
16 Okt 2011, 17.38.0716/10/11
kepadad3...@googlegroups.com
I ran into an issue with getting the transformed coordinates of an object (using it's bbox) when doing things in the resizable way with viewBox and preserveAspectRatio. I got it working so hopefully this code might be of some benefit



On Sat, Oct 15, 2011 at 3:09 PM, Chris Viau <christo...@gmail.com> wrote:
Look at this example and try resizing your window: http://christopheviau.com/d3_tutorial/d3_examples/ . Maybe it can help.



--
Ian Johnson

Sergiy Nesterko

belum dibaca,
19 Okt 2011, 14.41.3619/10/11
kepadad3-js
Great, thank you so much. Sergiy

Atl Ank

belum dibaca,
20 Sep 2016, 05.25.5520/09/16
kepadad3-js, mbos...@cs.stanford.edu
Hi,
Is there anyway svg will dynamically resize when the content size excceds the mentioned SVG width and height?.. Like contetnt overflows and i am not able to see  rest of the content outside the defined SVG width and height range. 

Thanks in adavnce for your reply.
Ank
Balas ke semua
Balas ke penulis
Teruskan
0 pesan baru