Java Reference
In-Depth Information
Chart
XYChart
PieChart
AreaChart
BarChart
BubbleChart
LineChart
ScatterChart
StackedAreaChart
StackedBarChart
Figure 8-1. Overview of the charts in the JavaFX Chart API
The abstract Chart class defines the setup for all charts. Basically, a chart consists of three parts: the title, legend,
and content. The content is specific for each implementation of the chart, but the legend and the title concepts are
similar across the implementations. Therefore, the Chart class has a number of properties with corresponding getter
and setter methods that allow the manipulation of those concepts. The javadoc of the Chart class mentions the
following properties.
BooleanProperty animated
ObjectProperty<Node> legend
BooleanProperty legendVisible
ObjectProperty<Side> legendSide
StringProperty title
ObjectProperty<Side> titleSide
We use some of these properties in the upcoming examples, but we also show that even without setting values for
these properties, the Chart API allows you to create nice charts.
Because Chart extends Region , Parent , and Node , all of the properties and methods available on these classes
can be used on a Chart as well. One of the benefits is that the same CSS styling techniques that are used to add style
information to JavaFX Node s also apply to JavaFX Chart s.
The JavaFX CSS Reference Guide , available at http://download.java.net/jdk8/jfxdocs/javafx/scene/
doc-files/cssref.html , contains an overview of CSS properties that can be altered by designers and developers.
By default, the modena style sheet that comes with the JavaFX 8.0 Runtime is used to skin JavaFX Charts. For more
information on using CSS styles in JavaFX Chart, refer to the Oracle Chart tutorial at http://docs.oracle.com/
javase/8/javafx/user-interface-tutorial/css-styles.htm .
Using the JavaFX PieChart
A PieChart renders information in a typical pie structure, where the sizes of the slices are proportional to the values of
the data. Before diving into the details, we show a small application that renders a PieChart .
 
Search WWH ::




Custom Search