score:0

Try converting the svg to canvas first. There is a project https://github.com/gabelerner/canvg out there, which may help you. After converting the svg, html2canvas should be able to render the snapshot correctly.

score:0

If we are only talking about styles that are set via style attributes, not using a stylesheet, then the following is an option that is independant of d3:

var svgElements = document.querySelectorAll("svg *");
Array.prototype.forEach.call(svgElements, function(svgElement){
  var styles = svgElement.getAttribute("style").split(";");
  styles.forEach(function(style){
    var styleComponents = style.split(":");
    svgElement.setAttribute(
      styleComponents[0].trim(),
      styleComponents[1].trim()
    );
  });
});

You'll have to modify the selector in the first line to match your use case.


Related Query

More Query from same tag