我在同一页面中有 2 个图表。我想仅在一个图表中显示图例,而不是在两个图表中显示图例,但我只有一个全局解决方案。这是我的 JavaScript 代码:
$.jqplot.preDrawHooks.push(function () {
this.legend.show = true;});
和我的xhtml:
<p:chart id="chart17" responsive="true" type="bar" model="#{chart17Bean.barModel}" />
<p:chart id="chart18" responsive="true" type="bar" model="#{chart18Bean.barModel}" />
已编辑:我正在使用 Primefaces 6.1
最佳答案
在页面上添加这个JS函数
function removeLegend()
{
this.cfg.legend = {
show: false
};
}
然后在你的托管bean中添加
barModel.setExtender("removeLegend");
其中barModel是您想要隐藏图例的图表模型。
关于javascript - 当同一 View 中有两个图表时,如何独立显示或隐藏 Primefaces 图表图例?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47184015/