I reach the end of an application including a nice chart panel of JFreeChart (v.1.0.10) with
- two (I had like three) series of the XYSeriesCollection class. One (I had like two) plots are of XYBarRenderer and another one of StandardXYItemRenderer.
- a variable number of vertical markers of different colors in the background, dynamically settable and removable.
[img]How%20to%20attach%20a%20picture%20file%20in%20a%20folder%20of%20my%20computer%20(no%20http://)?[/img].
The three data sets correspond to on-peak (XYBarRenderer), off-peak (StandardXYItemRenderer) and both ( XYBarRenderer preferably and of another color) power values.
Q1: What do I have to do to display a third plot (in a third color) ?
Code: Select all
public JFreeChart créerGraphique(ArrayList[] listes_PuissEnerg)
{
NumberAxis axeAbcisses = new NumberAxis("Puissance - KW"); // Domain
// axeAbcisses.setTickMarkPosition
ValueAxis axeOrdonnées = new NumberAxis("Energie - MWH"); // Range
IntervalXYDataset donnéesHPl, donnéesHPlHCr, donnéesHCr;
XYItemRenderer renduHPl, renduHPlHCr, renduHCr;
XYPlot plot;
if (listes_PuissEnerg != null)
{
donnéesHPlHCr = createDataset(listes_PuissEnerg[HPLEINESETCREUSES_IDX], HPLEINESETCREUSES_IDX);
renduHPlHCr = new XYBarRenderer(0.10);
renduHPlHCr.setBaseStroke(new BasicStroke(0.5f));
renduHPlHCr.setBaseToolTipGenerator(
new StandardXYToolTipGenerator(
StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
new DecimalFormat("0.0"), new DecimalFormat("0.000") ) );
plot = new XYPlot(donnéesHPlHCr, axeAbcisses, axeOrdonnées, renduHPlHCr);
donnéesHPl = createDataset(listes_PuissEnerg[HPLEINES_IDX], HPLEINES_IDX);
renduHPl = new XYBarRenderer(0.10);
renduHPl.setBaseStroke(new BasicStroke(0.5f));
renduHPl.setBaseToolTipGenerator(
new StandardXYToolTipGenerator(
StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
new DecimalFormat("0.0"), new DecimalFormat("0.000") ) );
plot = new XYPlot(donnéesHPl, axeAbcisses, axeOrdonnées, renduHPl);
donnéesHCr = createDataset(listes_PuissEnerg[HCREUSES_IDX], HCREUSES_IDX);
renduHCr = new StandardXYItemRenderer();
renduHCr.setBaseToolTipGenerator(
new StandardXYToolTipGenerator(
StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
new DecimalFormat("0.0"), new DecimalFormat("0.000") ) );
plot.setDataset(1, donnéesHCr);
plot.setRenderer(1, renduHCr);
plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
plot.setDomainCrosshairVisible(true);
plot.setRangeCrosshairVisible(true);
plot.setForegroundAlpha(0.675f);
// Set the domain axis (X) to display integers only ...
axeAbcisses = (NumberAxis) plot.getDomainAxis();
axeAbcisses.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
// Set the range axis (Y) to display integers only ...
axeOrdonnées = (NumberAxis) plot.getRangeAxis();
axeOrdonnées.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
} else
{ // Very first graph display, before first dataset filling.
plot = new XYPlot(null, axeAbcisses, axeOrdonnées, null);
}
// Add vertical markers ...
For each of the two datasets corresponding to the chart of the picture, I have about 3 x 150 values on the domain axis, ending respectively and randomly with ...,00 , ...,50 and ...,60. I don't know why; these are input data from a provider to take as are. One can observe that JFreeChart treat them such a way that it displays 3 layers of slighly shifted bar sets and of slighly different red intensities.
Many thanks by advance