Java JFreeChart Category Step Chart horizontal (image to explane)

前端 未结 1 512
广开言路
广开言路 2020-12-03 16:29


i need the following type of chart:
It should be a \"steped\" line chart with categories on the vertical axis, like this:

相关标签:
1条回答
  • 2020-12-03 17:11

    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

    0 讨论(0)
提交回复
热议问题