javascript - Error prerendering server of a pie chart with D3.js in svg format -
i'm using library d3.js
draw pie chart
.
to create chart use prerendering server side (nodejs) using gulp, , module npm jsdom
, save html file. , works.
// html saving // window jsdom obj var innerhtml = window.document.documentelement.innerhtml; var parser = require('parse5').parser, parser = new parser(), dom = parser.parse(htmlstring); save(xmlserializer.serializetostring(dom)); // save file
but need save in svg format
, use these functions convert html xml svg.
// svg saving // window jsdom obj var body = window.document.queryselector("html"); var svg = body.getelementsbytagname("svg")[0]; var svg_xml = xmlserializer.serializetostring(body); save(vkbeautify.xml(svg_xml));// save file
(npm modules: vkbeautify,xmlserializer )
i have done several graphics without problems, except pie chart: html perfect, svg rendered badly.
outputs:
what cause? how can fix?
it's lower/upper case issue. somewhere in code must lowercasing whole thing. result, path descriptor in output looks this:
m6.123031769111886e-15,-100a100,100 0 1,1 -3.8285889215894375e-14,100l0,0z
whereas need work is
m-95.10565162951534,-30.901699437494813a100,100 0 0,1 7.044813998280223e-14,-100l0,0z
in svg, there big difference between 2 (lowercase means "relative last position"; uppercase means "absolute coordinates).
Comments
Post a Comment