A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Post Reply
JFreeChart Project Leader
Posts: 11679
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.


Post by david.gilbert » Mon May 22, 2006 3:46 pm

Our list of frequently asked questions has been posted on the JFreeChart web site:

Feedback can be posted here.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Ask your company to buy the JFreeChart Developer Guide
:idea: Check out other products sold by my company Object Refinery Limited

Posts: 844
Joined: Fri Oct 13, 2006 9:29 pm
Location: Sunnyvale, CA

Post by RichardWest » Thu Sep 27, 2007 9:45 pm

Question: How can I change the color of my bar, line, point, etc. based upon its value?


Extend your renderer of choice and override the getItemPaint(...) method. For examples, see the following threads:

Configure Negative Bar Color
Changing BarChart bar colors. Is this possible?
Bar Chart - Bars with different colours

Different colours on a line between 2 data points (also discusses tabs in TextTitle)

All these examples can be applied to any situation. For a more extensive list of examples/discussions, seach the forum.
Richard West
Design Engineer II
Advanced Micro Devices
Sunnyvale, CA

Posts: 1633
Joined: Sat Feb 17, 2007 1:51 pm


Post by paradoxoff » Fri Sep 25, 2009 5:35 pm

Question: The number of tick marks is so high that they overlap/are truncated, and it is impossible to read them! What can I do?

The tick marks or "tick labels" are created by the axis. Axes that extend ValueAxis (DateAxis, NumberAxis, LogAxis...) will by default show the labels for as many ticks as possible without tick label overlap. A CategoryAxis will create a label for each unique column key in the respective CategoryDataset.

If your are dealing with overlappig tick marks, you have probably used a CategoryPlot with a CategoryDataset which has a too large number of column keys. Check whether the Comparable instances that you use as column keys are in fact Numbers or Dates. If that is the case, switch to an XYSeriesCollection or TimeSeriesCollection, and build an XYPlot. The ChartFactory contains a number of static methods to create those plots.

If you really need to use a CategoryDataset with a large number of column keys, you can try to wrap that in a SlidingCategoryDataset and expose only a subset of the original dataset to the plot at a time.

If this is not an option as well, you should hide the (useless) tick marks completely (axis.setTickLabelsVisible(false)). In a desktop enviroment (Swing GUI), you can still make the column keys visible by assigning a suitable CategoryToolTipGenerator to the renderer. You will probably want to show the column keys as tool tip. Check StandardCategoryToolTipGenerator as an example.

Post Reply