How do I display html encoded values in svg?

十年热恋 提交于 2019-11-29 15:29:39

HTML entities are not defined in SVG. You can either use the actual unicode character or use the foreignObject element to embed HTML into your SVG.

Since you are using d3js, you can use the unicode as well.

Example to append text to span:

svg.append('span')
   .text('Pound: ' + '\u00A3' + ' or ' + '\uFFE1');
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!