Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

D3JS SVG Viewbox Attribute

I am appending an svg to my div and applying a viewBox attribute of '0 0 100% 100%'. My console is stating an error from d3.js.

Error: Invalid value for <svg> attribute viewBox="0 0 100% 100%"

Here is snippet from the code

d3.select("#chart")
    .append("svg")
    .attr("viewBox", "0 0 100% 100%");

Is using percentages in a viewBox attribute allowed?

like image 596
someyoungideas Avatar asked Sep 06 '25 10:09

someyoungideas


1 Answers

a valid viewBox must consist of 4 numbers separated by whitespace and/or comma. Percentages are not allowed.

like image 150
Robert Longson Avatar answered Sep 08 '25 19:09

Robert Longson