javascript - 如何在模态中显示 primefaces 图表?

标签 javascript jsf primefaces charts size

我用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());
}

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

谢谢!

最佳答案

我想你可以试试这个方法:

<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

关于javascript - 如何在模态中显示 primefaces 图表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37766341/

相关文章:

javascript - 将字符串传递给弹出窗口

java - jsf 应用程序中的 org.apache.jasper.JasperException

java - 如何从 JSF 中的 PhaseEvent 获取调用方法的名称

java - JSF 1.2 中组合框的值更改时触发组合框的渲染

jsf - p :tooltip does not work as expected 的动态 "for"属性

jsf - 如何指定哪个 <p :messages> component to send message

javascript - 使用正则表达式捕获冒号和逗号之间的字符

javascript for 循环不起作用

javascript - 如何使用phaser框架在html5中实现设备定向

jsf - 如何选择 PrimeFaces TreeTable 中的所有内容?