class SeriesUtils {

    protected static int iBoundsMin(XYSeries series, double visibleMin, float step) {
        int min = 0;
        final int steps = (int) Math.ceil(series.size() / step);
        for (int stepIndex = 1; stepIndex <= steps; stepIndex++) {
            final int i = stepIndex * (int) step;
            for (int ii = 1; ii <= step; ii++) {
                final int iii = i - ii;
                if(iii < 0) {
                    break;
                }
                if(iii < series.size()) {
                    final Number thisX = series.getX(iii);
                    if (thisX != null) {
                        if (thisX.doubleValue() < visibleMin) {
                            // this is the largest non-null value in this block, so skip
                            // to the next block:
                            min = iii;
                            break;
                        } else if (thisX.doubleValue() == visibleMin) {
                            return iii;
                        } else {
                            return min;
                        }
                    }
                }
            }
        }
        return min;
    }

}