d3js响应力布局在IE 11中不起作用(d3js responsive force layout not working in IE 11)

编程入门 行业动态 更新时间:2024-10-24 12:22:34
d3js响应力布局在IE 11中不起作用(d3js responsive force layout not working in IE 11)

我正在使用d3.js的强制布局,我想使力布局能够响应。

我使用下面的代码:

var width = 1110 ,height = 600 ; svg = d3.select("#d3_drawing_container").append("svg:svg") .attr("viewBox", "0 0 " + width + " " + height ) .attr("overflow", "hidden") .append("g");

这在Firefox和Chrome中完美运行,但在Internet Explorer(IE版本:11.0.9600.16428)中,svg元素不会从viewbox属性获取高度。

I am using force layout of d3.js ,I wanted to make force layout to be responsive.

I have used below code:

var width = 1110 ,height = 600 ; svg = d3.select("#d3_drawing_container").append("svg:svg") .attr("viewBox", "0 0 " + width + " " + height ) .attr("overflow", "hidden") .append("g");

This works perfectly in Firefox and in chrome,but in Internet explorer (IE Version:11.0.9600.16428) svg element doesn't getting height from the viewbox property.

最满意答案

您也可以直接在<svg>元素上设置height和width 。

var width = 1110 ,height = 600 ; svg = d3.select("#d3_drawing_container").append("svg:svg") .attr("width", width).attr("height", height) .attr("viewBox", "0 0 " + width + " " + height ) .attr("overflow", "hidden") .append("g");

You can set the height and width directly on the <svg> element as well.

var width = 1110 ,height = 600 ; svg = d3.select("#d3_drawing_container").append("svg:svg") .attr("width", width).attr("height", height) .attr("viewBox", "0 0 " + width + " " + height ) .attr("overflow", "hidden") .append("g");

更多推荐

本文发布于:2023-08-05 09:38:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1431140.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:中不   布局   d3js   working   layout

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!