[Primefaces] Export/Imprimer un chart
Bonjour,
J'ai un chart que j'ai réaliser avec JSF 5.2 et j'aimerais pouvoir imprimer celui-ci avec un click sur un bouton.
Voici mon code
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<ui:composition>
<h:outputStylesheet library="css" name="style.css" />
<script type="text/javascript">
function exportChart() {
document.getElementById('outputChart').empty().append(
PF('chart').exportAsImage());
//show the dialog
PF('dlg').show();
}
</script>
<p:dialog widgetVar="dlg" showEffect="fade" modal="true"
header="Chart as an Image">
<p:outputPanel id="outputChart" layout="block"
style="width:500px;height:300px" />
</p:dialog>
<p:panelGrid columns="2" border="1">
<p:panelGrid columns="1" border="0">
<p:commandButton value="Print" type="button" icon="ui-icon-print"
onclick="exportChart()" />
<p:chart widgetVar="chart" type="line"
model="#{curves1.lineModel}"
style="height:800px;width:800px;" />
</p:panelGrid>
<p:chart type="line" model="#{curves2.lineModel}"
style="height:800px;width:800px;" />
</p:panelGrid>
</ui:composition>
</html> |
Avez-vous une solution pour imprimer un chart svp ?
Merci d'avance