Most charting tools allow you to stack bar and
area charts in different modes. Most common are regular stack
and 100% stack charts. Not only does Chart FX for Java allow
you to stack charts using these common methods, but you can
easily achieve MultiStacked charts where different series
in the chart can be presented as different groups of stacked
bar or area charts.
If you want to stack all series in the chart, you can use
the Stacked property as follows:
chart1.setStacked(Stacked.NORMAL);
chart1.setStacked(Stacked.STACKED_100);
|
The stacked property is also exposed by the Series object,
with the difference that it will apply to a specific series
in the chart. When you manipulate the Stacked property in
the Series object you will instruct Chart FX to stack
that series on top of the previous one, which must be of a
stacked type (area or bar). For example, the following code
creates a MultiStacked chart with a curve in front of the
different stacked groups:
chart1.getSeries(0).setGallery(Gallery.BAR); SeriesAttributes series2 = chart1.getSeries(1); series2.setGallery(Gallery.BAR); series2.setStacked(true);
chart1.getSeries(2).setGallery(Gallery.BAR); SeriesAttributes series4 = chart1.getSeries(3); series4.setGallery(Gallery.BAR); series4.setStacked(true);
SeriesAttributes series5 = chart1.getSeries(4); series5.setGallery(Gallery.BAR); series5.setStacked(true);
SeriesAttributes series6 = chart1.getSeries(5); series6.setGallery(Gallery.CURVE); series6.setColor(java.awt.Color.black);
chart1.recalcScale();
|
The previous code produces the following chart:

|