а

downloading chart as JPEG or PDF


#1

I have an issue while downloading charts drawn in dhtmlx. i have followed the post : http://forum.dhtmlx.com/viewtopic.php?f=8&t=19461 and have done the exact same things suggested in the post, however i can see the chart without labels. I can only see color and lines. Please help.


#2

Unfortunately, this is expected. Text labels is a separate layer, and you can’t export it with the above API
You can check the html2canvas project, it can be used to get a png file for any HTML document|widget
html2canvas.hertzen.com/


#3

I tried that… my code is somewhat like this:

var canvas = Mychart.getCanvas().canvas; var html2obj = html2canvas(canvas); var queue = html2obj.parse(); var canvas1 = html2obj.render(queue); var img = canvas1.toDataURL(); window.open(img);
but still i cannot see text. its just colours and lines, like in the attachement


#4

Please, try t use html2canvas to your chart but not to a ready generated canvas of a chart.


#5

Change line that gets an object to export, like next

var html2obj = html2canvas(Mychart.$view);

#6

ok, I’ve tried doing that @Stanislav and now my code looks like this: var html2obj = html2canvas(Mychart.$view); var queue = html2obj.parse(); var canvas1 = html2obj.render(queue); var img = canvas1.toDataURL(); window.open(img);
but it shows an error like this :

, which is coming in html2canvas function, part of code is as below: window.html2canvas = function (elements, opts) { elements = (elements.length) ? elements : [elements]; var queue,
What do i do now?


#7

The following code exports the barchart correctly on the page:

html2canvas(myBarCHart.$view, { onrendered: function(canvas) { document.body.appendChild(canvas); } });
and on the new page:

html2canvas(myBarCHart.$view, { onrendered: function(canvas) { var img = canvas.toDataURL(); window.open(img); } });