Creating scrollbars with SVG and d3.js

后端 未结 1 433
南笙
南笙 2021-02-08 21:21

Right now I\'ve used d3 to create several \"boxes\" that are merely SVG rectangles with text:

var canvas = d3.select(\"body\").append(\"svg\")
    .attr(\"width\         


        
相关标签:
1条回答
  • 2021-02-08 21:38

    Try to add the viewBox svg property:

    var rectangle = container.append("svg")
        .attr("viewBox", "0,0,150,420")
        .append("rect")
        .attr("width", 150)
        .attr("height", 420)
        .attr("fill", "steelblue")
        .attr("x", 0)
        .attr("y", 0);
    

    jsfiddle

    0 讨论(0)
提交回复
热议问题