SVG not rendering under IE (tested under IE 11)
See original GitHub issueHi, Max: Could this potentially be a bug? So here’s my html. Note that
.selector('#bird')
.css({
'background-image': 'circle.svg'
})
You can see the bird image references to ‘circle.svg’, a very simple svg:
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 17.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 312 312" enable-background="new 0 0 312 312" xml:space="preserve">
<circle cx="100" cy="100" r="40" stroke="black" stroke-width="3" fill="red" />
</svg>
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Cytoscape.js initialisation</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="http://cytoscape.github.io/cytoscape.js/api/cytoscape.js-latest/cytoscape.min.js"></script>
<script>
$(function(){ // on dom ready
var cy = cytoscape({
container: document.getElementById('cy'),
style: cytoscape.stylesheet()
.selector('node')
.css({
'height': 80,
'width': 80,
'background-fit': 'cover',
'border-color': '#000',
'border-width': 3,
'border-opacity': 0.5
})
.selector('.eating')
.css({
'border-color': 'red'
})
.selector('.eater')
.css({
'border-width': 9
})
.selector('edge')
.css({
'width': 6,
'target-arrow-shape': 'triangle',
'line-color': '#ffaaaa',
'target-arrow-color': '#ffaaaa'
})
.selector('#bird')
.css({
'background-image': 'circle.svg'
})
.selector('#cat')
.css({
'background-image': 'https://farm2.staticflickr.com/1261/1413379559_412a540d29_b.jpg'
})
.selector('#ladybug')
.css({
'background-image': 'https://farm4.staticflickr.com/3063/2751740612_af11fb090b_b.jpg'
})
.selector('#aphid')
.css({
'background-image': 'https://farm9.staticflickr.com/8316/8003798443_32d01257c8_b.jpg'
})
.selector('#rose')
.css({
'background-image': 'https://farm6.staticflickr.com/5109/5817854163_eaccd688f5_b.jpg'
})
.selector('#grasshopper')
.css({
'background-image': 'https://farm7.staticflickr.com/6098/6224655456_f4c3c98589_b.jpg'
})
.selector('#plant')
.css({
'background-image': 'https://farm1.staticflickr.com/231/524893064_f49a4d1d10_z.jpg'
})
.selector('#wheat')
.css({
'background-image': 'https://farm3.staticflickr.com/2660/3715569167_7e978e8319_b.jpg'
}),
elements: {
nodes: [
{ data: { id: 'cat' } },
{ data: { id: 'bird' } },
{ data: { id: 'ladybug' } },
{ data: { id: 'aphid' } },
{ data: { id: 'rose' } },
{ data: { id: 'grasshopper' } },
{ data: { id: 'plant' } },
{ data: { id: 'wheat' } }
],
edges: [
{ data: { source: 'cat', target: 'bird' } },
{ data: { source: 'bird', target: 'ladybug' } },
{ data: { source: 'bird', target: 'grasshopper' } },
{ data: { source: 'grasshopper', target: 'plant' } },
{ data: { source: 'grasshopper', target: 'wheat' } },
{ data: { source: 'ladybug', target: 'aphid' } },
{ data: { source: 'aphid', target: 'rose' } }
]
},
layout: {
name: 'breadthfirst',
directed: true,
padding: 10
}
}); // cy init
}); // on dom ready
</script>
</head>
<body>
<div id="cy" style="width:800px;height:600px"></div>
</body>
</html>
Under Chrome, it renders like this:
Under IE, it renders like this:
You can see that under IE, the SVG is not rendered at all.
Issue Analytics
- State:
- Created 9 years ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
SVG not rendering IE 11 - Stack Overflow
I had a similar issue and in my case it was because IE requires the viewBox attribute to be specified within the SVG...
Read more >(Not)Displaying SVG in IE 11 or Edge - MSDN - Microsoft
Hello,. Why can't IE 11 / Edge display SVG file with this content (and other browsers can)? : <?xml version="1.0" encoding="utf-8" ...
Read more >Simple SVG icon not displaying in IE11
When accessing the app in google chrome, icon displays fine but in IE 11 nothing shows. Upon inspecting the network log in IE...
Read more >SVG icons are not displaying IE 11 - Salesforce Developers
This is not a Lightning issue, but a browser compatibility issue. IE 9-11 does not support external resources for SVG. To use SVG...
Read more >SVG in Internet Explorer - CSS-Tricks
First things first, when I view this SVG on Microsoft Windows (displays fine on my Mac in Chrome, Firefox and Safari) the SVG...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
SVG rendering is different under the DOM compared to a canvas. I’ll test this out relatively soon, but I often do not have high hopes for anything IE-related.
Thanks!
The change I pushed allows for specifying the dimensions manually. It also gets the correct image dimensions automatically from IE. However, IE just doesn’t seem to be able to render (maybe just particular?) SVGs in canvas.
I tested in a Windows 10 VM with IE11 latest and Edge latest. Edge seems OK. IE doesn’t render the SVG. I tried with
gnu.svg
in the debug page.