Below piece of code does not work in IE 11, it throws a syntax error in the console
g.selectAll(".mainBars")
.append("text")
.attr("x", d => (d.part == "primary" ? -40 : 40))
.attr("y", d => +6)
.text(d => d.key)
.attr("text-anchor", d => (d.part == "primary" ? "end" : "start"));
Using d3.js
bipartite chart for visualization
This code causing the issue in above statement d=>(d.part=="primary"? -40: 40)
IE doesn't support the arrow notation as of now but there is a handy and fast way for transpiling your
ES6
codes toES5.1
for working inIE
. visit the Babel website then paste your codes in the left box and copy the right box code that is transpiled to the earlier version ofJavaScript
.For example, your code is transpiled to:
Avoid use of arrow functions if you need to support IE 11 as it is not supported
Change those to regular functions and your code should work as you expect
In general, before arrow functions were arrow functions, they were regular JS
function
s. So with IE11 we just have to take a step back in timeYou're using arrow functions. IE11 doesn't support them. Use
function
functions instead.Here's Babel's translation of that to ES5: