javascript - How to get exact amount of stroke-dasharray on circle and rect? -


i trying figure out how svg file works. found out amount of stroke-dasharray of path using javascript:

var path = document.queryselector(".aa") path.gettotallength(); 

when checkout svg file there 3 elements. first 1 path, second 1 rect, , last circle.

the console keeps showing error messages on rect , circle. there solution this?

here original code:

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="imacsvg" x="0" y="0" viewbox="0 0 1800 1200" xml:space="preserve" enable-background="new 0 0 1800 1200">       <path d="m423.5 251.1c0 0 1.2-25.2 23.6-25.2 22.3 0 909.9 0.7 909.9 0.7s19.5-0.6 19.5 21.4 0 597 0 597 1.5 21.5-21.5 21.5 -909 0-909 0 -22.5-1.4-22.5-21.8c423.5 824.2 423.5 251.1 423.5 251.1z" class="aa"/>       <rect x="466.6" y="271.6" width="865.5" height="540" class="bb"/>       <circle cx="900.5" cy="246" r="8.2" class"cc"/> </svg> 

the gettotallength() function available <path> elements. need find different solution <rect> , <circle>.

obviously, circle, can use (2 * r * pi), , rect can use (2 * (width + height)).