jquery - 加载页面时如何添加 JQPlot 类以隐藏所有图表线?
问题描述
我的 Primefaces JQPlot 折线图应用程序中有太多系列,我想加载已隐藏线条的图表;然后,用户将单击所需的图例以在图表中显示相应的线(参见此示例)。
模板.xhtml 文件:
<h:body onload="HideSeries()" >
<!-- [unrelevant code ommited] -->
</h:body>
<script>
function HideSeries() {
$('#chartsFormID\\:lineChartID').toggleClass('jqplot-series-hidden');
}
</script>
我的 index.xhtml 文件:
<h:form id="chartsFormID" >
<p:accordionPanel multiple="false" dynamic="true" cache="true" >
<p:tab title="myTab title">
<p:chart type="line" id="lineChartID" model="#{bean.myChart}" />
</p:tab>
</p:accordionPanel>
</h:form>
不幸的是,它不起作用。
谁能帮帮我吗 ?
提前致谢。
解决方案
要将类添加到所有元素,请尝试以下操作:
$('tr.jqplot-table-legend td').toggleClass('jqplot-series-hidden');
或者你可以触发所有元素的点击事件:
$('tr.jqplot-table-legend td').trigger('click');
推荐阅读
- c# - RedirectToAction 没有正确重定向到我需要的 routeValue
- java - 创建 RabbitMQ 队列失败
- reactjs - Multiline JS expressions inside JSX are forbidden
- linux - don't understand the difference between "gcc -c file.c" and "gcc -o file.c" command
- reactjs - React Context Provider does not update the value when it is in a Router Switch
- c# - Unit test for Serilog write to console
- .htaccess - 使用 .htaccess 重写 PHP URL
- javascript - Is there any way to use separate alignment for title key and data elements in a table?
- c# - C# 中的问题套接字 TCP IP 在停止之前仅收到来自客户端的一条消息
- python - 从数据集中在 seaborn 的线图中创建多条线