dhtmlxChart Export feature

Helo,
Can you Please give us export functionality like in html2canvas that allows you to save an html element as an image.

You can use the above lib already, without any modifications in the DHTMLX code

    //assuming that you have included html2canvas.js 
    //and chart was initialized in the chartDiv container
    function getImageData(link, area, name){
        var data;
        html2canvas( document.getElementById('chartDiv'), {
            onrendered: function(canvas) {
                data = canvas.toDataURL()
                link.href = data;
                link.download = name;
            }
        });
    }

	</script>
    <a onmousedown='getImageData(this, "chartDiv", "mychart.png")' href='#'>Download chart</a>

Code like next will work in latest browsers.

Could you explaing a bit more around the function you stated in your answer?

function getImageData(link, area, name){ var data; html2canvas( document.getElementById('chartDiv'), { onrendered: function(canvas) { data = canvas.toDataURL() link.href = data; link.download = name; } }); }

I am not very used to work with html an my knowledge is limited :slight_smile:

If i create a button on my site that calls the function getImageData is should also add 3 parameters (link, area, name). Can you give an example or explain what these values mean, where to use them in my html?

Thanks

Parameters

  • html link, it will be updated to point to the image download after function run
  • id of html container in which chart was rendered
  • name of export file

If you are placing the same code in the html link, the only thing what need to be changed is a second parameter - if of chart’s html container ( the same value, that was used in charts initialization )