Simple Fix and some Questions

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Taoufik Romdhane

Simple Fix and some Questions

Post by Taoufik Romdhane » Tue Jan 15, 2002 5:24 pm

Hi all!
Congratulations, you've done a great work!!!
So, I tried this lib and found that VerticalBarRenderer3D causes an exception if a vertical 3d bar graph has only one category, I read the comments of the method drawBar(...) then found the problem rectX was a NaN! so I copied a fix from VerticalBarRenderer as below:

/*
// BAR X
double rectX = plotArea.getX()
// intro gap
+ plotArea.getWidth()*plot.getIntroGapPercent()
// bars in completed categories
+ categoryIndex*categorySpan/data.getCategoryCount()
// gaps between completed categories
+ (categoryIndex*categoryGapSpan/(data.getCategoryCount()-1))
// bars+gaps completed in current category
+ (series*itemSpan/(data.getCategoryCount()*data.getSeriesCount()))
+ (series*itemGapSpan/(data.getCategoryCount()*(data.getSeriesCount()-1)));
*/
double rectX = plotArea.getX()+plotArea.getWidth()*plot.getIntroGapPercent();

int categories = data.getCategoryCount();
int seriesCount = data.getSeriesCount();
if (categories>1) {
rectX = rectX
// bars in completed categories
+ categoryIndex*(categorySpan/categories)
// gaps between completed categories
+ (categoryIndex*(categoryGapSpan/(categories-1))
// bars+gaps completed in current category
+ (series*itemSpan/(categories*seriesCount)));
if (seriesCount>1) {
rectX = rectX
+ (series*itemGapSpan/(categories*(seriesCount-1)));
}
}
else {
rectX = rectX
// bars+gaps completed in current category
+ (series*itemSpan/(categories*seriesCount));
if (seriesCount>1) {
rectX = rectX
+ (series*itemGapSpan/(categories*(seriesCount-1)));
}
}


so, I have 2 question:
1. concerning the class BarPlot:

MAX_INTRO_GAP_PERCENT = 0.10;

I find this too little (I wanted more: about 0.20) otherwise the bars looks fat and too flat!
But if you check:
public void setIntroGapPercent(double percent) {
if (this.introGapPercent!=percent) {
this.introGapPercent = Math.min(percent, MAX_INTRO_GAP_PERCENT);
notifyListeners(new PlotChangeEvent(this));
}
}
then check plz for negative values!

2. I can't change the tick unit, can anyone help me please?

Thank you for the great and useful lib!
Sincerely,
Taoufik

David Gilbert

RE: Simple Fix and some Questions

Post by David Gilbert » Wed Jan 16, 2002 9:47 am

Hi Taoufik,

Thanks for the feedback.

Feel free to change MAX_INTRO_GAP_PERCENT - I may increase it to 0.20 for the next version. It's just a little sanity check really. I'll also add an argument check for negative values. I've been adding checks to methods here and there as I go along and it has uncovered one or two bugs, so that is good.

Setting the tick size:

Hmm, there should be a setTickUnit(...) method in the NumberAxis class, but there isn't! I'll add one in the next release.

Regards,

DG.

Taoufik Romdhane

RE: Simple Fix and some Questions

Post by Taoufik Romdhane » Wed Jan 16, 2002 10:12 am

Hi David!
Thank you for the answer. I made an error in my fix of yesterday (it had a problem when a graph has more than one category).
Sorry because of my buggy fix...
but here is the new one
class VerticalBarRenderer3D


// BAR X
double rectX = plotArea.getX()+plotArea.getWidth()*plot.getIntroGapPercent();

int categories = data.getCategoryCount();
int seriesCount = data.getSeriesCount();
if (categories>1) {

rectX = plotArea.getX()
// intro gap
+ plotArea.getWidth()*plot.getIntroGapPercent()
// bars in completed categories
+ categoryIndex*categorySpan/data.getCategoryCount()
// gaps between completed categories
+ (categoryIndex*categoryGapSpan/(data.getCategoryCount()-1))
// bars+gaps completed in current category
+ (series*itemSpan/(data.getCategoryCount()*data.getSeriesCount()));
if (seriesCount>1) {
rectX += (series*itemGapSpan/(data.getCategoryCount()*(data.getSeriesCount()-1)));
}

Regards,
Taoufik

Locked