use of com.db.chart.model.ChartEntry in project WilliamChart by diogobernardino.
the class AxisRenderer method findBorders.
/**
* Find out what are the minimum and maximum values of the
* axis based on {@link ChartSet} values.
*
* @param sets {@link ArrayList} containing {@link ChartSet} elements of chart
*
* @return Int vector containing both minimum and maximum value to be used.
*/
int[] findBorders(ArrayList<ChartSet> sets) {
float max = Integer.MIN_VALUE;
float min = Integer.MAX_VALUE;
// Find minimum and maximum value out of all chart entries
for (ChartSet set : sets) {
for (ChartEntry e : set.getEntries()) {
if (e.getValue() >= max)
max = e.getValue();
if (e.getValue() <= min)
min = e.getValue();
}
}
max = (max < 0) ? 0 : (int) Math.ceil(max);
min = (min > 0) ? 0 : (int) Math.floor(min);
// All given set values are equal
if (min == max)
max += 1;
return new int[] { (int) min, (int) max };
}
Aggregations