0

I am using this d3 Javascript library: https://bl.ocks.org/d3noob/43a860bc0024792f8803bba8ca0d5ecd

When i use Google Chrome it works fine, but when I use Internet Explorer 11. I get an error in:

 path = `M ${s.y} ${s.x}
                                 C ${(s.y + d.y) / 2} ${s.x},
                                    ${(s.y + d.y) / 2} ${d.x},
                     ${d.y} ${d.x}`

The problem is the sign `. I know that Internet Explorer and Chrome "read" code differently, but how can i modify my code to work in Internet Explorer or in both?

TheAsker
  • 55
  • 1
  • 9
  • Apparently IE11 [doesn't support template literals](https://stackoverflow.com/a/40872280/8237835). You can probably modify the code (laboriously) by using plain quotes `"` instead and then replacing all of the `${...}` with string concatenation like we used to do in the old days. Also, is there any particular reason for this spacing? Because that might make things slightly harder. – Khauri Nov 16 '18 at 13:35
  • No don't mind the spacing. Can you give an example of how you would write it ? – TheAsker Nov 16 '18 at 13:41
  • Looks like Zim's got you covered in his answer – Khauri Nov 16 '18 at 13:50

1 Answers1

1

If template literals are not supported, just build the path by concatenating Strings and variables as you would have done prior ES6:

path = "M " + s.y + " " + s.x + " C " + ((s.y + d.y) / 2) + " " + s.x + ", " + ((s.y + d.y) / 2) + " " + d.x + ", " + d.y + " " + d.x;
Zim
  • 1,457
  • 1
  • 10
  • 21