简体   繁体   English

D3.js没有显示在Firefox中

[英]D3.js not showing in firefox

I can not run this visualization on firefox, while I can do it on Chrome and even on Edge : 我无法在firefox上运行此可视化,而可以在Chrome甚至Edge上运行:

https://naustud.io/tech-stack/ https://naustud.io/tech-stack/

Since I was very inspired by it and wanted to analyze it - I am a beginner with d3.js -, the fact that this visualization can not be rendered on all browsers is a bit of a drag on my approach. 由于我受到了启发,并且想对其进行分析(我是d3.js的初学者),因此无法在所有浏览器上呈现此可视化效果的确有点拖累我的方法。 .

Does anyone have an explanation? 有人有解释吗? Can this be solved? 这可以解决吗? Thank you everyone. 谢谢大家。

It seems like in Firefox, the clientWidth of the svg element isn't being read, possibly related to this bug: https://bugzilla.mozilla.org/show_bug.cgi?id=874811 . 似乎在Firefox中,未读取svg元素的clientWidth ,可能与此错误有关: https : clientWidth Instead the width variable is being set to 0, and that looks like it causes infinite recursion when trying to pack the chart. 而是将width变量设置为0,并且看起来在尝试打包图表时会导致无限递归。

To correct this, you can use .node().parentNode.clientWidth (via How to get SVG element dimensions in FireFox? ), by adding this before the console.log in techstack-main.js (Line 490): 要更正此问题,可以通过在techstack-main.js中console.log之前添加以下内容来使用.node().parentNode.clientWidth (通过如何在FireFox中获取SVG元素尺寸? )(第490行):

if (!width) {
  width = svg.node().parentNode.clientWidth;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM