i need the following type of chart:
It should be a "steped" line chart with categories on the vertical axis, like this:
I found this example of an Category Step Chart, but it the orientation is not right for my purpose.
All i have done so far is this, but as you can see the red line does not fit to the orientation of the chart(should be horizontal):
The corresponding code to this:
DefaultCategoryDataset ds = new DefaultCategoryDataset();
// create dataset
for (int k = 0; k < ffCount; k++) {
StateSignal ss1 = (StateSignal) this.ffDSet.getFframes().get(k).getSignals().get(i);
ds.setValue((double) k + 1, ss1.getName(), ss1.getStates().get(0).getStatus());
}
CategoryStepRenderer categorysteprenderer = new CategoryStepRenderer(false);
categorysteprenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
CategoryAxis categoryaxis = new CategoryAxis("Category");
NumberAxis numberaxis = new NumberAxis("Value");
CategoryPlot categoryplot = new CategoryPlot(ds, categoryaxis, numberaxis, categorysteprenderer);
categoryplot.setRangePannable(true);
categoryplot.setOrientation(PlotOrientation.HORIZONTAL);
chart = new JFreeChart("test", null, categoryplot, true);
I don´t get it to work. Any ideas?
Thanks in advance!
It looks like you need to use a standard XYLineChart with a
XYStepRenderer
and aSymbolAxis
to replace the default Range Axis rather than aCategoryStepRenderer
and a horizontal plot orientationIf you associate Status A and B with a numerical value say 1 and 2 you can create a chart like this:
Using this a
XYStepRenderer
and a
Symbol Axis
In this example the
SymbolAxis
provides an alternative label for each value in the Axis