No, I don’t believe there is any such tag or attribute to set the viewBox so 
that it will hold all drawn contents of a drawing. I could see the value, 
though, of what you’re saying: doing it declaratively instead of via script. As 
it is, I believe you’d have to do as Yannick says: render all content inside a 
<g> and, upon the load of the svg, measure the <g> with getBBox(). If you’re 
using D3, then you have access to JavaScript (not all viewers do), so it 
shouldn’t matter too much (the computational efficiency of getBBox() should 
work pretty efficiently as a function of the number of drawn objects in the 
<g>, though I suppose the complexity of the objects would affect this as well)

 

Good luck

David

 

From: svg-developers@yahoogroups.com [mailto:svg-developers@yahoogroups.com] On 
Behalf Of Alireza
Sent: Friday, April 06, 2012 9:31 AM
To: svg-developers@yahoogroups.com
Subject: [svg-developers] Re: showing full svg content whithout calculating 
extents

 

  

Thanks, I wished I could find a tag or attribute for this but this is also 
useful. 

Anyhow thanks
--- In svg-developers@yahoogroups.com <mailto:svg-developers%40yahoogroups.com> 
, yannick.bochatay@... wrote:
>
> Hi,
> if all your shapes are included in a g element, you can use the getBBox 
> method on this node to get the dimensions.
> In your example :
> document.getElementById('G2').getBBox()
> 
> Yannick
> 
> ----- Mail original -----
> De: "Alireza" <ahmadi_rad@...>
> À: svg-developers@yahoogroups.com <mailto:svg-developers%40yahoogroups.com> 
> Envoyé: Jeudi 5 Avril 2012 10:19:19
> Objet: [svg-developers] showing full svg content whithout calculating extents
> 
> 
> 
> 
> 
> 
> Hello 
> 
> I need help for finding extents of an svg drawing. Please take a look at this 
> example: 
> 
> <svg id="SVG1" width="5cm" height="5cm" viewBox="0 -100 200 200"> 
> <g id="G2"> 
> <line x1="0" y1="0" x2="100" y2="100" stroke="blue"/> 
> <line x1="0" y1="0" x2="0" y2="100" stroke="blue"/> 
> <line x1="0" y1="0" x2="100" y2="0" stroke="blue"/> 
> <line x1="0" y1="0" x2="100" y2="-100" stroke="blue"/> 
> </g> 
> </svg> 
> 
> For this sample it was easy to understand that viewBox="0 -100 200 200" will 
> fit the whole drawing. But in my real world application this will not be so 
> easy to calculate this. And without this viewbox or with incorrect 
> calculations, at least a part of drawing will not be shown which is not 
> desirable. 
> 
> I want to show the whole drawing in svg without getting involved in 
> calculating the extents. Something like zoom extents in aoutocad. could you 
> please help? 
> 
> Thanks
>





[Non-text portions of this message have been removed]



------------------------------------

-----
To unsubscribe send a message to: svg-developers-unsubscr...@yahoogroups.com
-or-
visit http://groups.yahoo.com/group/svg-developers and click "edit my 
membership"
----Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/svg-developers/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/svg-developers/join
    (Yahoo! ID required)

<*> To change settings via email:
    svg-developers-dig...@yahoogroups.com 
    svg-developers-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
    svg-developers-unsubscr...@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

Reply via email to