'How to create a dual X-axis chart with jfreeChart? Timeline with sprint names

I'm struggling with the dual X-axis chart with jfree chart. After a few trials with a chart customizer it still doesn't work. I would like to have events based labels on the axis that are in my datasource. The problem is the second x-axis does not show. Here is my code:

public class BurnupTimelineChartCustomizer extends JRAbstractChartCustomizer {
private static final String Y_AXIS_MAX_VALUE = "yaxisMaxValue";

private static final String EXPECTED_TOTAL_SCOPE = "expectedTotalScope";
@Override
public void customize(JFreeChart chart, JRChart jasperChart) {

    Double yaxisMaxValue = (Double) this.getParameterValue(Y_AXIS_MAX_VALUE);
    Double expectedTotalScope = (Double) this.getParameterValue(EXPECTED_TOTAL_SCOPE);
    CategoryPlot plot = chart.getCategoryPlot();

    // Value Marker
    ValueMarker marker = new ValueMarker(Math.max(yaxisMaxValue,expectedTotalScope));
    marker.setPaint(Color.black);
    plot.addRangeMarker(marker);
    // Dual Axis
    CategoryAxis sprintAxis = new CategoryAxis("TimeLine Axis");
    plot.setDomainAxis(1, sprintAxis );
    plot.mapDatasetToDomainAxis(1, 1);      // Range Axis

    ValueAxis rangeAxis = plot.getRangeAxis();
    rangeAxis.setUpperBound(Math.max(expectedTotalScope, yaxisMaxValue) +100);
    rangeAxis.setLowerBound(0.);
    rangeAxis.setVisible(false);

    // Dashed line
    LineAndShapeRenderer lineAndShapeRenderer = new LineAndShapeRenderer(true, true);
    lineAndShapeRenderer.setSeriesPaint(0,Color.black);
    lineAndShapeRenderer.setBaseItemLabelsVisible(Boolean.TRUE);
    lineAndShapeRenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());

    plot.setRenderer(lineAndShapeRenderer);
}}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source