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");更多推荐
发布评论