Search code examples
javauser-interfacejfreechart

how to make values in X axis horizontal in a JFreeChart?


I am working with JFreeChart in java in order to show some charts. I want to make the value in the X axis vertical to save the space between two dots in the chart ( line chart ).

The picture below shows what i mean:

enter image description here

Thanks


Solution

  • Try it:

    ...
    XYDataset dataset = createDataset();
    JFreeChart chart = createChart(dataset);
    CategoryAxis categoryAxis = chart.getCategoryPlot().getDomainAxis();
    categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
    // categoryAxis.setVerticalTickLabels(true);
    ...