Reputation: 605
I use jasperreports and I try to display some additional data beyond the x-axis labels of a line chart and I'm facing several problems. The values I want to display are stored in a field, which's values need to be printed horizontally and they also have to be exactly beyond the correlating x-axis labels of the chart. Also the number of x-axis labels can change dynamically (but are always the same number as the field values to be printed below the labels), depending on the chosen report period. Here is an example of a chart with four labels on the x-axis.
Is there away to accomplish all the requirements?
Upvotes: 3
Views: 3674
Reputation: 605
I finally figured out how to do it. The image shows my solution. This time I have done it with a BAR CHART, but it also works with a LINE CHART of course. I kind of abused a bar chart to match my specifications. Beneath the static text element "Additional Data" I put another bar chart with the field data I want to show, as the values of the category expression. Everything else is just hidden (for example by giving it the background color). I hide the axis and labels and reduced the size of the report element to "50". It seems that you can't make it smaller because then the tick labels of the category axis disappear. What you have to take care of is that there can not be duplicate category expression values, because they will be unified into one label. I fixed this by implementing a new class which implements the compareable interface so that I can create Objects with the same toString() representation but having different ids. I know this is a HACK, but at least it seems to work and it looks (kind of) as I wanted it to look like. If anyone has a better solution please tell me about it.
Upvotes: 1
Reputation: 3548
I had the same issue and i didn't find any solution, what you can do you can create a tabular report below to the line chart where you can display the values. You can add mouse over property to the line chart.
Otherwise create a new tabular report with the same query and hyperlinked this report with the line chart, let the user decide whether he wants to see the values also or not and if he want to see data points he can drill down the report.
Upvotes: 0