The caption of a Primefaces chart does not appear when I download the image

When the chart is loaded, the caption loads together, but when I download the image the caption does not appear..

Download button:

<p:commandLink onclick="return downloadImage();" 
    style="margin: 2%;">
    <h:graphicImage url="/RESOURCES/icons/grafico/download.png"
        styleClass="ui-image-icon-excel" style=" margin-top: 5%;" />
</p:commandLink>

Download button Javascript:

[![<script type="application/javascript">
               function downloadImage(){
               var image = PF('chart').exportAsImage();
               var imageSrc = $(image).attr('src');
               var url = imageSrc.replace(/^data:image\/\[^;\]+/, 'data:application/octet-stream');
               var link = document.createElement('a');
               link.download = "chart.png";
               link.href = url;
               document.body.appendChild(link);
               link.click();
               document.body.removeChild(link);
               return false;
            }
            </script>][1]][1]

Download Image (caption is blank): insert the description of the image here

Author: Leandro Kojima, 2019-01-14

1 answers

Solved.

Just put in the PanelGrid css that surrounds the graph: text-align: left;

 0
Author: Leandro Kojima, 2019-01-15 13:13:47