0

I have an XYLineChart, where the labels on the X axis are written horizontally. I would like to be able to write them vertically (descending).

I can already do this for BarCharts:

CategoryPlot plot = (CategoryPlot) chart.getPlot();
final CategoryAxis domainAxis = plot.getDomainAxis();
domainAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_90);

but an XYChart returns an XYPlot, rather than a CategoryPlot, and the getDomainAxis() of an XYPlot returns a ValueAxis, not a CategoryAxis. ValueAxis lets me call

setVerticalTickLabels(true);

which is almost there! But it draws them ascending, rather than descending. Any way around this?

Thanks,

Edit: I need the domain axis to stay at the bottom of the chart. Hadn't considered it being any other way when making the original post.

woddle
  • 1,582
  • 1
  • 18
  • 34

2 Answers2

1

ValueAxis does this automatically in drawTickMarksAndLabels() for an axis on the RectangleEdge.TOP edge:

xyPlot.setDomainAxisLocation(AxisLocation.TOP_OR_LEFT);

enter image description here

Example based on a variation of ScatterAdd.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • Thanks. I need the labels on the bottom, rather than the top, though. I've had to modify the source to achieve this. – woddle Dec 12 '11 at 09:04
1

Answering my own question, this didn't seem to be possible, so I had to add the functionality to the jfreechart source myself.

woddle
  • 1,582
  • 1
  • 18
  • 34