Creating interactive charts using the ItemSelect AJAX event
All of the PrimeFaces chart components support the itemSelect
AJAX event which gets triggered when a series of charts are clicked on. The itemSelect
event listener method receives an org.primefaces.event.ItemSelectEvent
instance from which we can obtain an item index and a series index.
<p:growl id="growl" showDetail="true"/> <p:pieChart value="#{chartController.pieChartModel}" style="width: 350px; height: 250px;" showDataLabels="true" legendPosition="ne"> <p:ajax event="itemSelect" listener="#{chartController.itemSelect}" update="growl"/> </p:pieChart> public void itemSelect(ItemSelectEvent event) { FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Item selected", "Item Index: " + event.getItemIndex() + ", Series Index:" + event.getSeriesIndex()); FacesContext...