Java JFreeChart Category Step Chart horizontal (image to explane)

It looks like you need to use a standard XYLineChart with a XYStepRenderer and a SymbolAxis to replace the default Range Axis rather than a CategoryStepRenderer and a horizontal plot orientation

If you associate Status A and B with a numerical value say 1 and 2 you can create a chart like this:

enter image description here

Using this a XYStepRenderer

  XYStepRenderer renderer = new XYStepRenderer();
  renderer.setBaseShapesVisible(true);
  renderer.setSeriesStroke(0, new BasicStroke(2.0f));
  renderer.setSeriesStroke(1, new BasicStroke(2.0f));
  renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
  renderer.setDefaultEntityRadius(6);
  plot.setRenderer(renderer);

and a Symbol Axis

  String[] grade =  new String[3];
  grade[0] = "";
  grade[1] = "Status A";
  grade[2] = "Status B";
  SymbolAxis rangeAxis = new SymbolAxis("", grade);
  rangeAxis.setTickUnit(new NumberTickUnit(1));
  rangeAxis.setRange(0,3);
  plot.setRangeAxis(rangeAxis);

In this example the SymbolAxis provides an alternative label for each value in the Axis

Leave a Comment