I am creating a custom chart using SVG and I am having problems while dealing with text on IE. I have the SVG file being loaded through an EMBED tag and I can access it through JavaScript. This is a line chart and the lines are being positioned correctly. The problem is that I want to change the text of the scale to the values on the JavaScript, but I can't make it work on IE.
Below is the code snippet that handles this:
Expand|Select|Wrap|Line Numbers
- var newText = svg_doc.createElementNS(svgNS,"text");
- newText.setAttributeNS(null,"x",100);
- newText.setAttributeNS(null,"y",100);
- newText.setAttributeNS(null,"font-size","13px");
- newText.setAttributeNS(null,"text-anchor","middle");
- newText.setAttributeNS(null,"fill-opacity",Math.random());
- var red = Math.round(Math.random() * 255);
- var green = Math.round(Math.random() * 255);
- var blue = Math.round(Math.random() * 255);
- newText.setAttributeNS(null,"fill","rgb("+ red +","+ green+","+blue+")");
- var textNode = document.createTextNode("a new text");
- newText.appendChild(textNode);
On Firefox this would be quite simple using something like this:
Expand|Select|Wrap|Line Numbers
- var text_el = svg_doc.getElementById('value');
- text_el.textContent = 'something';
Any help would be really appreciated,
Thanks a lot in advance,
Regards,
Igor