问题
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