12.15 Using a List to Display a Pie Chart
JavaFX includes classes that make it easy to display various types of charts, including line charts, pie charts, and bar charts. To display a chart, we first create a list that stores the data we want to display. We then assign that data to the appropriate chart object. After we include the chart object in a scene, the chart draws itself automatically. The ObservableList interface, from the javafx.collections package, is a list that can be linked to a GUI component, such as a ComboBox. Whenever the values in the list change, the associated GUI component is automatically updated to reflect those changes. Several chart classes, such as PieChart and BarChart, can be constructed by linking their data to ...
Get Java Illuminated, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.