I'm trying to create an SVG bar graph using jQuery AND NO OTHER LIBRARIES but when I create my rectangles they don't show up in the browser although identical ones typed into the html do show up.
var data = [4, 8, 15, 16, 23, 42];
var chart = jQuery("#chart");
jQuery.each(data, function(index, value) {
var bar = jQuery("<rect/>");
chart.append(bar);
bar.attr("y", index * 20)
.attr("width", value * 10)
.attr("height", 20);
});
and the html:
<svg id="chart" class="chart" width=420 height=120 style="display: block;">
<rect y="0" width="40" height="20"></rect> <!--added to test-->
</svg>
The rect tag typed in appears just fine and using the developer tools in Chrome it appears identical to the first one produced by my code but the code generated ones won't show up.