A very basic SVG/JavaScript question: How do you set the width and height of an SVG object (polygon, path, ellipse, etc.) via JavaScript?
This is my first interactive SVG after years of working in ActionScript. I'm just trying to set the height of bars in a bar chart dynamically. I've gotten quite a ways into this project setting fill color and visibility of various objects with pedestrian code like this:
targetbar=document.getElementById("rep"+loopcount);
targetbar.setAttribute("visibility", "visible");
But plugging height
and a number into the setAttribute
command does not work, nor has anything else I've copied from various code snippets found online.
Thinking that I'd keep this first project as plain-vanilla as possible, I haven't been using any external libraries. At least for now I'm looking for a solution that doesn't involve JQuery, Raphael, D3, etc.