0

I know how to create a CategoryPlot and then set the DomainAxis labels to use two lines. This is the idea:

CategoryAxis categoryAxis = categoryPlot.getDomainAxis();
categoryAxis.setMaximumCategoryLabelLines(2); // Mmmm... nice labels

But I'm having trouble doing "the same thing" for a Timeseries chart. The problem is that the DateAxis is a ValueAxis rather than a CategoryAxis. That makes sense because the dates are values. But I don't like the look of the chart when it uses only a single line for the date. You can see a sample chart in my answer in this thread. I want to format my dates to use 2 lines. But I cannot do it like this:

DateAxis dateAxis = (DateAxis)xyPlot.getDomainAxis();
dateAxis.setMaximumCategoryLabelLines(2); // method does not exist

How can I get those Date labels onto 2 lines?

Community
  • 1
  • 1
mdahlman
  • 9,204
  • 4
  • 44
  • 72

1 Answers1

1

Using setVerticalTickLabels(), shown here, may alleviate the horizontal crowding; using setDateFormatOverride() may mitigate the resulting vertical space cost.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • Yuck. And by "Yuck", I mean: I tested and it works like you suggested. Thanks. But vertical text will make it very hard to show data and time info. I need to stick with horizontal text. I'll just use `setDateFormatOverride` unless someone can offer a way of breaking the label onto 2 lines. – mdahlman Feb 21 '12 at 20:55
  • I guess you could use a sparser `TickUnit` and reveal the detail in a tooltip, for example. – trashgod Feb 21 '12 at 21:21