jQWidgets Forums
Forum Replies Created
-
Author
-
September 27, 2017 at 3:50 am in reply to: Exporting chart to image and get the src of image Exporting chart to image and get the src of image #96335
Hey @Peter. I have thoroughly read the example and read the source code through inspect element. This does not satisfy my use case as I do not want to download the image to my browser (like this example does), Rather I want to convert that chart to image data / URL accessible within the javascript program and use that image to put it in PDF or any other purpose.
Is there no solution currently for this one.September 22, 2017 at 5:01 pm in reply to: Chat image export request from server Chat image export request from server #96263Hi Mallikarjun,
I am facing the same issue. Did you find out a way to embed charts into PDF.
September 22, 2017 at 7:49 am in reply to: Exporting chart to image and get the src of image Exporting chart to image and get the src of image #96245One of your stack overflow links is about converting an image-url to pdf. This one would work. But how do I get a url to the image.? I can only download it to local client.
September 22, 2017 at 7:40 am in reply to: Exporting chart to image and get the src of image Exporting chart to image and get the src of image #96244Hi Stanilav,
Thanks for the response. Actually, the export example downloads the PNG image to the browser.Now, my chart is dynamic and will change whenever user changes data. Hence, I think downloading image and hard coding file path to reference it in PDF doesn’t seem right.
Is there any way to programmatically convert chart to canvas element or a data-url? This is one such example from Chart.js to illustrate what I would require. JSFiddle link is given.
http://jsfiddle.net/canvasjs/cm1qyk2L/
var chart = new CanvasJS.Chart("chartContainer", { title: { text: "Exporting chart using jsPDF & toDataurl" }, data: [ { type: "spline", dataPoints: [ { x: 10, y: 4 }, { x: 20, y: 7 }, { x: 30, y: 2 }, { x: 40, y: 3 }, { x: 50, y: 5 } ] } ] }); chart.render(); var canvas = $("#chartContainer .canvasjs-chart-canvas").get(0); var dataURL = canvas.toDataURL(); //console.log(dataURL); $("#exportButton").click(function(){ var pdf = new jsPDF(); pdf.addImage(dataURL, 'JPEG', 0, 0); pdf.save("download.pdf"); });
-
AuthorPosts