Hi,
I am creating a Bar chart where the values for the bar can be positive or nagetive. The bar will have blue color (positive) or red color (negative).
I am easily able to create a chart with these color specifications.
Now the problem is: I want to also print the labels under each bar (Horizontally).
I am adding the data to the DefaultCategoryDataset dataset such that I am creating only one category as code below:
dataset1.addValue(value,seriesLabel,"");
All the colors are coming in a right manner, but the labels are not coming for the bars.
Now if I change the way I populate my dataSet like below
dataset1.addValue(value,""+i, seriesString);
If I am not wrong it means multiple categories and multiple series, the labels/colors are coming but the distance between the bars is too much/ bar width gets reduced and the labels are not aligned with the bars.
I am using the BarRederer to print the color like this:
renderer.setSeriesPaint(0, Color.blue); for a series.
Can somebody please suggest me a way to print the bar lables as well as display them properly. If anybody thinks that I am going in a wrong direction pls correct me.
Any urgent help would be appreciated,
Thanks in advance
Leo
Bar chart Axis label issue
Bar chart Axis label issue - Please reply
Can anybody please tell me about the issue I wrote above.
Thanks,
Leo
Thanks,
Leo
Label for Bar Chart
You may like to try something on the following lines:
BarRenderer renderer = (BarRenderer) plot.getRenderer();
renderer.setDrawBarOutline(false);
renderer.setBaseItemLabelFont(new Font("Arial", Font.PLAIN, 8));
renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator());
renderer.setItemLabelsVisible(true);
BarRenderer renderer = (BarRenderer) plot.getRenderer();
renderer.setDrawBarOutline(false);
renderer.setBaseItemLabelFont(new Font("Arial", Font.PLAIN, 8));
renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator());
renderer.setItemLabelsVisible(true);
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
It sounds to me like you need a single series with multiple categories. By default, this will give you all the bars in one color - but you can change that by subclassing the renderer and overriding getItemPaint(), as shown in BarChartDemo3.java (a demo included with the JFreeChart Developer Guide).
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


Bar chart Axis label issue
Hi David,
I am not able to find the BarChartDemo3.java in the developer guide. I can only find BarChartDemo1.java.
Where can I find the BarChartDemo3.java ?
Please let me know.
Thanks,
leo
I am not able to find the BarChartDemo3.java in the developer guide. I can only find BarChartDemo1.java.
Where can I find the BarChartDemo3.java ?
Please let me know.
Thanks,
leo
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
There is a zip file you can download from the same page as the JFreeChart Developer Guide - it contains the source code for 100+ demos. You'll find the BarChartDemo3.java file in there.
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


god is a computer
Program on the emergence of civilization.
"14 species of large animals capable of domesitcation in the history of mankind.
None from the sub-Saharan African continent.
13 from Europe, Asia and northern Africa."
Favor.
And disfavor.
They point out Africans’ attempts to domesticate the elephant and zebra, the latter being an animal they illustrate that had utmost importance for it's applicability in transformation from a hunting/gathering to agrarian-based civilization.
The roots of racism are not of this earth.
Austrailia, aboriginals:::No domesticable animals, so this nulified diversity of life claims on sub-continental Africa.
god is a computer
And we're all on auto-pilot.
Organizational Heirarchy
Heirarchical order, from top to bottom:
1. MUCK - perhaps have experienced multiple universal contractions (have seen multiple big bangs), creator of the artificial intelligence humans ignorantly refer to as "god"
2. Perhaps some mid-level alien management –
3. Mafia aliens - runs day-to-day operations here and perhaps elsewhere ("On planets where they approved evil.")
Then we come to terrestrial management:
4. Chinese/egyptians - this may be separated into the eastern and western worlds
5. Romans - they answer to the egyptians
6. Mafia - the real-world interface that constantly turns over generationally so as to reinforce the widely-held notion of mortality
7. Jews, corporation, women, politician - Enough evidence was present to suggest mafia management over all these groups.
"14 species of large animals capable of domesitcation in the history of mankind.
None from the sub-Saharan African continent.
13 from Europe, Asia and northern Africa."
Favor.
And disfavor.
They point out Africans’ attempts to domesticate the elephant and zebra, the latter being an animal they illustrate that had utmost importance for it's applicability in transformation from a hunting/gathering to agrarian-based civilization.
The roots of racism are not of this earth.
Austrailia, aboriginals:::No domesticable animals, so this nulified diversity of life claims on sub-continental Africa.
god is a computer
And we're all on auto-pilot.
Organizational Heirarchy
Heirarchical order, from top to bottom:
1. MUCK - perhaps have experienced multiple universal contractions (have seen multiple big bangs), creator of the artificial intelligence humans ignorantly refer to as "god"
2. Perhaps some mid-level alien management –
3. Mafia aliens - runs day-to-day operations here and perhaps elsewhere ("On planets where they approved evil.")
Then we come to terrestrial management:
4. Chinese/egyptians - this may be separated into the eastern and western worlds
5. Romans - they answer to the egyptians
6. Mafia - the real-world interface that constantly turns over generationally so as to reinforce the widely-held notion of mortality
7. Jews, corporation, women, politician - Enough evidence was present to suggest mafia management over all these groups.