d3 doesn't append namespace attributes to svg element

前端 未结 1 1752
闹比i
闹比i 2021-01-18 15:28

I wonder why D3.js doesn\'t add the namespace attributes to the SVG element.

d3.ns.prefix.ex = \'http://example.com/\';
var chart = d3.select(\'#chart\').app         


        
相关标签:
1条回答
  • 2021-01-18 15:54

    namespace attributes are only relevant when documents are served as some XML mime type e.g. image/svg+xml.

    namespaces don't do anything in html markup such as jsfiddle so d3 doesn't need to create them.

    If you want namespaces then you could add the attributes manually in html or alternatively switch to xhtml where the attributes will be automatically created.

    0 讨论(0)
提交回复
热议问题