* @param update
* true if updating chart layout
*/
public void adjustRange(boolean update) {
if (isValidCategoryAxis()) {
setRange(new Range(0, categorySeries.length - 1));
return;
}
double minimum = Double.NaN;
double maximum = Double.NaN;
for (ISeries series : chart.getSeriesSet().getSeries()) {
int axisId = direction == Direction.X ? series.getXAxisId()
: series.getYAxisId();
if (!series.isVisible() || getId() != axisId) {
continue;
}
// get axis length
int length;
if (isHorizontalAxis) {
length = chart.getPlotArea().getSize().x;
} else {
length = chart.getPlotArea().getSize().y;
}
// get min and max value of series
Range range = ((Series) series).getAdjustedRange(this, length);
if (Double.isNaN(minimum) || range.lower < minimum) {
minimum = range.lower;
}
if (Double.isNaN(maximum) || range.upper > maximum) {
maximum = range.upper;
}
}
// set adjusted range
if (!Double.isNaN(minimum) && !Double.isNaN(maximum)) {
if (minimum == maximum) {
double margin = (minimum == 0)? 1d : Math.abs(minimum / 2d);
minimum -= margin;
maximum += margin;
}
setRange(new Range(minimum, maximum), update);
}
}