mdahlman
mdahlman

Reputation: 9400

How to set max label lines for Date Ticks in JFreeChart Timeseries plots

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?

Upvotes: 0

Views: 1595

Answers (1)

trashgod
trashgod

Reputation: 205875

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

Upvotes: 1

Related Questions