JasperReports: How to mask or filter the labels at

2020-04-11 11:13发布

I´m using a simple area chart based on a simple Dataset like this:

DateTime(sql.timestamp) |Value(Integer)
2012-02-17 00:02:02     |100
2012-02-17 00:02:08     |110
2012-02-17 00:02:20     |90
2012-02-17 00:02:35     |10
2012-02-17 00:02:40     |130
2012-02-17 00:04:22     |14
2012-02-17 00:04:33     |45
2012-02-17 00:05:02     |60
...

DateTime is used by Category Axis, Value is used by Range Axis.
In the Dataset are ~1000 Records
In the Labels of the Category Axis will every DateTime Value be shown.
But that is with 1000 records too much, the Category Labels will be shown as Black Line.
And that is my problem.
I´d tried to (un)check all "Chart Properties". With no results.
Did i have to Mask or filter the labels?
I´d tried to change the values of:
Category Tick Label Mask
Category Axis Vertical Tick Labels
(This checkbox doesn´t takes effect)

Label Expression of the Category Axis

All in Several ways. But it won´t work. Each dataset will create an own Label.

Other report engines that i have used has calculated the Cat. Axis dynamic.
But JasperReports?

I´m using iReport 4.5.0 with (actual) jfreechart 1.0.14

EDIT

If i use a timeseries Chart, JasperReports will group the data by Intervall (Year, month,...) and that not Dynamicly

But the look of the chart is quite good, so it is that what i want. Only the Labels has to be located far from each other.

Here a fine Example (advsoft phpChartdirector) that is OK

Here the JasperReports / IReport example:

not OK. Take a look to the cat. Axis

not OK. Take a look to the cat. Axis

So.. What´s to do ?

End EDIT

Kind Regards Christian

1条回答
姐就是有狂的资本
2楼-- · 2020-04-11 11:57

Use a Timeseries chart instead of a Line chart. You should get exactly what you're looking for that way.

EDIT: I tested with your supplied .jrxml and data. It works well: Nice Time Series Chart

But... there seems to be a bug in iReport. You cannot set the time period in the iReport GUI. Perhaps this is what is causing you problems. It was very confusing to me. iReport generates this regardless of what time period you attempt to choose:

<timeSeriesDataset>

But you need to manually change the JRXML to this:

<timeSeriesDataset timePeriod="Second">

Once you do that, then you'll get a nice chart. At least iReport doesn't remove the correct timePeriod info... so you only have to do it once.

Note: If you're concerned about details like getting your date info to display on 2 lines, this is possible as well. I hate being stuck with a single line. I wrote an article about that last year. Look for the section Category Labels on multiple lines.

查看更多
登录 后发表回答