client

d3.js responsive chart 하는 법

void 2020. 7. 2. 10:00
width = 500;
height = 500;

const svg = d3
  .select("#chart")
  .append("svg")
  .attr("viewBox", `0 0 ${width} ${height}`)

위코드처럼 viewBox를 추가해주면 된다.

출처 : https://stackoverflow.com/questions/9400615/whats-the-best-way-to-make-a-d3-js-visualisation-layout-responsive

댓글수0