如何将 xmlns 和 xlink 属性插入到 c3 图表生成的 svg element/tag 中?

how to insert xmlns and xlink attributes into svg element/tag generated by c3 charts?

我打算使用 https://github.com/Xportability/css-to-pdf 导出 c3 图表。但是 CSS2PDF 要求 SVG 标签包含属性 xmlns="http://www.w3.org/2000/svg" 和 xmlns:xlink="http://www.w3.org/1999/xlink" 对出口有效。

如何将这两个属性添加到c3图表生成的svg元素中?

$(document).ready(function () {
        var svg = $('#chart').find('svg')[0];
    svg.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
    svg.setAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');

     });