I think this has been asked before and I have found several references but still can't make it work so a little help please.
I was using Google Charts but for several reasons I have to switch so I have converted to d3 charts which for the most part have done everything I need but I still have one small problem. I need to generate a PDF files. I was using the getImageURI function from Google charts and passing that data to the server.
I tried the below code but the PDF generator says the image is invalid so I must be doing something wrong. Suggestions on how to fix it? I am using the latest version of d3, would prefer not to bounce off a outside server, and can't use anything from Google servers.
How can I simulate the getImageURI from Google Charts with d3?
Google code:
var img: any = chart.getImageURI();
d3 code:
function getChartImage(chartId: string): string {
var svg: any = d3.selectAll('svg').attr("version", 1.1).attr("xmlns", "http://www.w3.org/2000/svg");
var html: any = svg.node().parentNode.innerHTML
var img: string = "data:image/svg+xml;base64," + btoa(html);
return img;
}
var img: any = getChartImage("chart_div");