Jump to content
We've recently updated our Privacy Statement, available here ×

Category dataset labels


vinays84

Recommended Posts

For charts that utilize a category dataset (the line chart), I'd like to know if its possible to print only select labels.

 

My problem is that I have a chart which plots 90 points (category = date) and, as a result, the category axis gets littered with 90 dates printing, rendering it unreadable. I'd like to print every other or every third date, if possible, but retain the values for these dates being plotted. Essentially, I'd like to hide some of the category labels. Is this possible?

 

Thanks!

Link to comment
Share on other sites

  • 3 months later...
  • Replies 6
  • Created
  • Last Reply

Top Posters In This Topic

Good question, similar to about a hundred others asking about the formatting of iReport chart labels that have not been answered.

 

I have been battling with this issue for days now and before anyone suggests RTFM: the F* manual is useless!!

 

Maybe the site mods can group all these chart posts together and actually answer the question or address the issue that the charts are not really usable if there are more than a couple of data points as the labels cannot be read?

Link to comment
Share on other sites

Hi,

 

I can certainly understand your frustration of having so many questions about charts not answered.

Why are they not answered? Probably because JasperReports is not a chart rendering library.

If fully relies on another library called JFreeChart for drawing the charts.

 

What we do in JR and iR is to expose approximately 80% of the "most common" chart settings that one might use with "normal" chart types.

Of course, we can always argue about what is "most common" or "normal chart type". Depending who you ask, people would say the chart settings they need are the most important and should be supported by JR/iR in their chart components.

 

However, even if we expose a limited set of JFreeChart features, we let everybody make the best of what the actual charting library can do for them.

You can call the JFreeChart API directly using what we call a chart customizer. It is an implementation of the JRChartCustomizer interface that you can associate with your chart element in the report.

 

You can check the /demo/samples/charts folder of the JR project distribution and see how we make use of a bar chart customizer there.

Knowing this, you could now say only JFreeChart is the limit to what you can do with the chart element in JR/iR. If you find a chart limitation with approach, note that you can pick any other Java charting package that you might like and embed charts as images elements in the report, just like we've shown in the /demo/samples/jcharts and /demo/samples/jfreechart samples.

 

I hope this answers 80% of the "most common" chart questions on this forum.

 

Thanks,

Teodor

Post edited by: teodord, at: 2008/02/14 14:08

Link to comment
Share on other sites

  • 1 year later...
That's all well and good, but I don't think you'd find anybody arguing that having data labels NOT cut off on bar charts is outside of that 80%. There doesn't seem to be an answer for that beyond "use a smaller font" and even that doesn't help. How can I keep bar labels from being cut off?
Link to comment
Share on other sites

  • 5 months later...

problem solved.

if you want to move the item label out of the bar, you will use Chart Customizer. There is sample customizer class in samples/charts/BarChartCustomizer.

well, you will;

ItemLabelPosition position = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.CENTER);
renderer.setPositiveItemLabelPosition(position);

that makes your chart looks like;


__2__
|      |
|      |

instead of;

_____
|  2  |
|      |

Link to comment
Share on other sites

  • 3 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...