2

Please refer below rect code.

<rect id="container_svg_ChartArea" x="146.8" y="20" width="633.2" height="414" fill="White" stroke-width="1" stroke="Gray"></rect>

i tried get the rectangle bounding box value it returns nothing i.e."0" for x=0,y=0,width=0,height=0

$("#container_svg_ChartArea")[0].getBBox()

but when i get the attribute for x/y/width/height it returns some value

$("#container_svg_ChartArea").attr("x") ->value returned.

same for path element as well as rectangle element.

what is going wrong?

no solution provide here.

how to get bounding box or rect (getBBox()) for svg path in jquery

thats why i created another thread. it is not duplicate thread.

Thanks,

Siva

Community
  • 1
  • 1
SivaRajini
  • 7,225
  • 21
  • 81
  • 128
  • possible duplicate of [how to get bounding box or rect (getBBox()) for svg path in jquery](http://stackoverflow.com/questions/16377186/how-to-get-bounding-box-or-rect-getbbox-for-svg-path-in-jquery) – Robert Longson May 06 '13 at 07:17
  • Please provide a jsfiddle with your bug, your code works correctly for me: http://jsfiddle.net/duopixel/UdLtx/ – methodofaction May 06 '13 at 19:05
  • i want to get the rectangle or box for grouped svg path. please refer below jsfiddle. http://jsfiddle.net/gFJyC/ – SivaRajini May 07 '13 at 04:53
  • document.querySelector("#container_svg_ChartArea").getBBox(); – tdjprog Apr 04 '19 at 07:00

1 Answers1

0

Look this example on how to get and manage the bounding box of svg elements

http://www.janvas.com/illustrators_designers_developers/projects/janvas2D_web/examples_EN.php?exampleName=ufo_animation_EN

in general

var svgElement = document.getElementById('the id of your element');
bbox = svgElement.getBBox();

console.log( bbox.x ) ;
console.log( bbox.y ) ;
console.log( bbox.width ) ;   
console.log( bbox.height ) ; 
Rik Del Mar
  • 209
  • 3
  • 6