IE10 d3.v3.js error: Unable to get property 'prototype' of undefined or null reference

岁酱吖の 提交于 2019-12-03 04:55:25

This can be fixed with a DOCTYPE:

<!DOCTYPE html>

And a meta tag:

<meta http-equiv="X-UA-Compatible" content="IE=edge" />

Without those, IE will go into quirks mode and not understand what CSSStyleDeclaration is.

Had same problem which used to happen randomly, after some research i concluded that it's setting invalid css properties ( from IE point of view ) that caused it, in my case: someSvg.append('svg:text') .text(function (d) { return d.label; }) .attr('text-anchor', 'left')

Where it should have been

.attr('text-anchor', 'start')

So my advice would be to review all from-scritpt-stylings, or even better - move them to css completely. After such fix it should work like charm in IE9+

It looks like this is a known issue and unlikely to get fixed.

https://groups.google.com/forum/?fromgroups=#!topic/d3-js/8lQ2BCR45BM

The work-around is to load d3 selectively - this works for me -

// load d3.js selectively
try { 
            // if this doesnt throw an error then we can load d3.js 
            // this is known to fail in IE < 8
            document.createElement("div").style.setProperty("opacity", 0, "")

            var d3Script = document.createElement( "script" )

            d3Script.src = "@Href("~/JavaScript/d3.js")"

            d3Script.onload = function (){
                // do stuff
            }

            document.getElementsByTagName("head")[0].appendChild( d3Script )
} catch( error ) {
            // upgrade your browser
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!