【问题标题】:How show a primefaces chart in a modal?如何在模态中显示primefaces图表?
【发布时间】:2016-06-11 17:00:49
【问题描述】:

我使用 javascript 生成图像并在模态中显示结果,但图像离开模态:http://s2.subirimagenes.com/imagen/9603018modal.png

这是我的代码:

XHTML

<h:form id = "form1">
    <p:chart widgetVar="chart" style="width:1200px;height:400px" type = "bar" model="#{graphicBean.barModel}" rendered="#{not empty graphicBean.barModel}"/>
    <p:commandButton onclick ="exportChart()" value = "Execute"/>
    <b:commandButton class="btn btn-primary" value="Show" ajax="true" oncomplete="$('.modalGraphic').modal();return false;" />
</h:form>

<b:modal id="id_modalGraphic" styleClass="modalGraphic" title="Guarda el gráfico">
     <h:form id = "resultado">
         <h:panelGroup id="output" layout="block" style="width:100px;height:100px"></h:panelGroup>
    </h:form>
</b:modal>

JavaScript

function exportChart() {
  $('#resultado\\:output').empty().append(PF('chart').exportAsImage());
}

我想要一张短图片或带卷轴的原始尺寸图片。

谢谢!

【问题讨论】:

  • 也许模态有一些溢出的css来显示东西而不是滚动?图像在模态中的位置是否正确?

标签: javascript jsf primefaces charts size


【解决方案1】:

我觉得你可以试试这个方法:

<p:commandButton value="Modal" type="button" onclick="PF('dlg2').show();" />

<p:dialog header="Modal Dialog" widgetVar="dlg2" modal="true" height="100">

    here goes what you want to show in the modal

</p:dialog> 

这是使用primefaces

【讨论】:

  • uhmmm 这就是 OP 正在做的事情。 outputPanel 在对话框中。并且 OP 想要将图表中的图像附加到它(导出的图像)上,这就是 jQuery 部分正在做的事情..
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-12-19
  • 1970-01-01
  • 2013-02-12
  • 1970-01-01
  • 1970-01-01
  • 2023-03-13
相关资源
最近更新 更多