Let us consider the use of events. We will add handling of a slice shift out to the screen created in Section 1.4.3, “Creating Charts”. Open the screen XML descriptor in the IDE and inject the chart:
@Inject
private Chart pieChart;Then add a listener in the initPieChart() method:
pieChart.addSlicePullOutListener(new Chart.SlicePullOutListener() {
@Override
public void onPullOut(Chart.SlicePullOutEvent event) {
BooksByGenre booksByGenre = (BooksByGenre) event.getItem();
String msg = booksByGenre.getGenre() + ": " + booksByGenre.getCountOfBooks() + " book(s)";
showNotification(msg, NotificationType.HUMANIZED);
}
});
To see the results, rebuild the project using -> and log in to the system. Open the screen and click one of the pie slices to shift it out.


