#88 StackedXYBarRenderer and negative values...

closed-out-of-date
David Gilbert
None
5
2005-10-07
2005-07-15
No

StackedXYBarRenderer has problems drawing negative values.

getPreviousHeight method should return sum of values
only with same sign as current value. In this case
negative bars going to stack in right direction.

protected double getPreviousHeight(XYDataset data, int
series, int index) {
double result = getBase();

double tmp;
double curValue = data.getYValue(series, index);
if (curValue >= 0) {
for (int i = 0; i < series; i++) {
tmp = data.getYValue(i, index);
if (!Double.isNaN(tmp) && tmp >= 0) {
result += tmp;
}
}
} else {
for (int i = 0; i < series; i++) {
tmp = data.getYValue(i, index);
if (!Double.isNaN(tmp) && tmp < 0) {
result += tmp;
}
}
}
return result;
}
}

Discussion

  • David Gilbert
    David Gilbert
    2005-10-07

    • assigned_to: nobody --> mungady
    • status: open --> closed-out-of-date