I'm trying to generate an image from a graph built in c3.js The code I have generates an image from an svg element. I'm basing myself on this code,but I modified the code to not download the image, only to generate the base64 of the image.:
http://bl.ocks.org/Rokotyan/0556f8facbaf344507cdc45dc3622177
Everything works but the result is not as expected.
My final conclusion is that the css classes defined in file c3.css are omitted. I tested with a code that does not use c3.js, this svg element only depends on its own styles,this works good!:
http://plnkr.co/edit/pFjNgPVsJdw6Mm9gixBA?p=preview
To check my theory, just comment on the css code that uses c3.js and the graph will look the same as when it is generated. Maybe if I can add the css code directly to the tag style of the element svg this could work. It is an assumption, if someone wants to try something else or get it to work, I will be very grateful.
This is my code with my problem:
http://plnkr.co/edit/FUSyckmj0mK1mq4Gp2Zo?p=preview
//element svg
var svgString = getSVGString(d3.select("#chart svg").node());
//generating image, the output is a base64 that will be the src of my img tag
svgString2Image( svgString, 800, 600, 'png' );
//show base64
console.log(svgString2Image( svgString, 800, 600, 'png' ))