Primefaces 5.2 从 p:chart 获取 jqplot 实例

Primefaces 5.2 get jqplot instance from p:chart

我的网站上有 p:chart 这样的

<p:chart id="chart" type="line" widgetVar="chart" model="#{resultsViewController.areaModel}" style="height:600px"/>

现在我希望客户端能够在不重新加载页面的情况下修改一些显示选项,为此我需要获取 jqplot 实例。我该怎么做?

我听说你可以这样做: http://forum.primefaces.org/viewtopic.php?f=3&t=24667

但是这样使用

 $('#chart').data('jqplot').plot.replot( { resetAxes: true } );

不产生 data() 函数

P.S 我知道可以为图表扩展 Primefaces 渲染器,但这对我来说不是一个选项。

好的所以我找到了答案感谢有用的 link 在 PF 客户端 API:

http://blog.hatemalimam.com/intro-to-primefaces-widgetvar/

所以简短的回答是,您需要分配一个 widgetVar 属性,然后使用 PrimeFaces 对象获取 jqplot 的实例,如下所示:

 <p:chart id="chart" type="line" widgetVar="chart" model="#{resultsViewController.areaModel}" style="height:600px"/>

像这样:

var jqplot = PrimeFaces.widgets.chart