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

Asked

Viewed 41 times

0

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

Button to download:

<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>

Javascript from download button:

[![<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): inserir a descrição da imagem aqui

1 answer

0


Solved.

Just put it in the css of the panelGrid that wraps the chart: text-align: left;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.