12.16 Using a List to Display a Dynamic Bar Chart

In this example, we display a bar chart that displays projected values of stocks and bonds over 4 years for an initial investment of $100. The BarChart class can be used to create a two-dimensional bar chart. A BarChart is defined using a horizontal axis, a vertical axis, and a list consisting of one or two series of data, each series representing a single-dimensional list of data. Thus, if we use only one series in that list, we can define a one-dimensional bar chart as a special case of a two-dimensional bar chart. Our example uses two series of data, one for stocks and one for bonds. The projected values of the bonds are fixed, but the projected values of the stocks toggle between two sets ...

Get Java Illuminated, 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.