如何使D3仪表图响应? [英] How to make d3 gauge chart responsive?

查看:49
本文介绍了如何使D3仪表图响应?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以帮助我调整d3仪表图的大小吗?这是 Stackblitz 代码.

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

我尝试过

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

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

推荐答案

请修改您的render()并添加

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')

这篇关于如何使D3仪表图响应?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆