use of org.eclipse.swtchart.Range in project swtchart by eclipse.
the class Series method getYRange.
/**
* Gets the Y range of series.
*
* @return the Y range of series
*/
public Range getYRange() {
double min = minY;
double max = maxY;
Axis xAxis = (Axis) chart.getAxisSet().getXAxis(xAxisId);
if (isValidStackSeries() && xAxis.isValidCategoryAxis()) {
for (int i = 0; i < stackSeries.length; i++) {
if (max < stackSeries[i]) {
max = stackSeries[i];
}
}
}
return new Range(min, max);
}
use of org.eclipse.swtchart.Range in project swtchart by eclipse.
the class BarSeries method getAdjustedRange.
/*
* @see Series#getAdjustedRange(Axis, int)
*/
@Override
public Range getAdjustedRange(Axis axis, int length) {
// calculate a range which has margin
Range range;
int lowerPlotMargin;
int upperPlotMargin;
if (axis.getDirection() == Direction.X) {
double lowerRiserWidth = getRiserWidth(xSeries, 0, axis, minX, maxX);
double upperRiserWidth = getRiserWidth(xSeries, xSeries.length - 1, axis, minX, maxX);
lowerPlotMargin = (int) (lowerRiserWidth / 2d + MARGIN_AT_MIN_MAX_PLOT);
upperPlotMargin = (int) (upperRiserWidth / 2d + MARGIN_AT_MIN_MAX_PLOT);
range = getXRange();
} else {
range = getYRange();
if (range.upper < 0) {
range.upper = 0;
}
if (range.lower > 0) {
range.lower = axis.isLogScaleEnabled() ? minY : 0;
}
lowerPlotMargin = (range.lower == 0) ? 0 : MARGIN_AT_MIN_MAX_PLOT;
upperPlotMargin = (range.upper == 0) ? 0 : MARGIN_AT_MIN_MAX_PLOT;
}
return getRangeWithMargin(lowerPlotMargin, upperPlotMargin, length, axis, range);
}
use of org.eclipse.swtchart.Range in project olca-app by GreenDelta.
the class ContributionChart method setYRange.
private void setYRange(List<Contribution<?>> top, double rest) {
double min = rest < 0 ? rest : 0;
double max = rest > 0 ? rest : 0;
for (Contribution<?> item : top) {
min = Math.min(min, item.amount);
max = Math.max(max, item.amount);
}
double[] range = yrange(min, max);
IAxis y = chart.getAxisSet().getYAxis(0);
y.setRange(new Range(range[0], range[1]));
y.getTick().setTickMarkStepHint(10);
}
Aggregations