How to make d3 gauge chart responsive?

独自空忆成欢 提交于 2021-02-08 10:19:28

问题


Can anyone help me to resize the d3 gauge chart? Here is the Stackblitz code.

I've tried,

.attr("preserveAspectRatio", "xMinYMin meet")

and

window.addEventListener("resize", this.draw);

回答1:


Please modify your render() and add

        svg = d3.select(container)
      .append('svg')
      .attr('class', 'gauge')
      .attr('width', '100%')
      .attr('height', '100%')
      .attr('viewBox', '0' + ' ' + '0'+ ' ' + config.clipWidth + ' ' + config.clipHeight)
     .attr('preserveAspectRatio', 'xMinYMin')


来源:https://stackoverflow.com/questions/52659198/how-to-make-d3-gauge-chart-responsive

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!