In this article, we will guide you on how to add PDF download as an option in a Chart DataPage.

Steps:

  1. Create a Chart DataPage.
  2. In the Configure Chart Options screen of the DataPage wizard, select Chart Settings > Enable chart actions menu.
  3. Add a Header and Footer in the Configure Chart Options screen of the DataPage wizard.
  4. Disable the HTML Editor in the Footer section.
  5. Copy and paste the following code in the Footer section:
  6. Save the DataPage.

Note: This article uses external HTML, JavaScript, or third-party solutions to add functionality outside of Caspio standard feature set. These solutions are provided “as is” without warranty, support, or guarantee. The code within this article is provided as a sample to assist you in the customization of your web applications. You may need a basic understanding of HTML and JavaScript to implement successfully.

For assistance with further customization based on your specific application requirements, please contact our Professional Services team.

code1
<script type = "text/javascript" >
    var timer = setInterval(function() {
        //Find if chart exists using rect element every x milliseconds
        if (document.getElementsByTagName('rect') != null) {
            //Update Chart
            UpdateChart();
        }
    }, 500);
function UpdateChart() {
    try {
        Highcharts.charts[0].update({
    exporting: {
       menuItemDefinitions: {
            // Custom definition
           downloadPDF: {
                text: 'Download as PDF'
            }
        },
        buttons: {
            contextButton: {
                menuItems: ['printChart', 'separator', 'downloadPDF', 'downloadPNG',  'downloadJPEG', 'downloadSVG',]
            }
        }
    }
});
        //Stop checking
        clearInterval(timer);
    } catch (err) {
        //log errors
    }
}; 
</script>