Our list of frequently asked questions has been posted on the JFreeChart web site:
http://www.jfree.org/jfreechart/faq.html
Feedback can be posted here.
FREQUENTLY ASKED QUESTIONS
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
FREQUENTLY ASKED QUESTIONS
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader
![Idea :idea:](./images/smilies/icon_idea.gif)
![Idea :idea:](./images/smilies/icon_idea.gif)
-
- Posts: 844
- Joined: Fri Oct 13, 2006 9:29 pm
- Location: Sunnyvale, CA
Question: How can I change the color of my bar, line, point, etc. based upon its value?
Answer:
Extend your renderer of choice and override the getItemPaint(...) method. For examples, see the following threads:
BarRenderer:
Configure Negative Bar Color
Changing BarChart bar colors. Is this possible?
Bar Chart - Bars with different colours
XYRenderer:
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.
Answer:
Extend your renderer of choice and override the getItemPaint(...) method. For examples, see the following threads:
BarRenderer:
Configure Negative Bar Color
Changing BarChart bar colors. Is this possible?
Bar Chart - Bars with different colours
XYRenderer:
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
Design Engineer II
Advanced Micro Devices
Sunnyvale, CA
-
- Posts: 1634
- Joined: Sat Feb 17, 2007 1:51 pm
Re: FREQUENTLY ASKED QUESTIONS
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?
Answer:
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.
Answer:
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.