for (int i = 0; i < datasets.size(); i++) {
Dataset dataset = datasets.get(i);
final String rangeAxisId = dataset.getAxisId(0);
RangeAxis rangeAxis = id2rangeAxis.get(rangeAxisId);
// Determine if the rangeAxis should be added to the left or right range panel
int numLeftAxes = leftPanel.getChildCount();
int numRightAxes = rightPanel.getChildCount();
boolean useLeftPanel = (numLeftAxes <= numRightAxes);
CompositeAxisPanel compositePanel = useLeftPanel || !plot.isMultiaxis() ? leftPanel : rightPanel;
if (rangeAxis == null) {
rangeAxis = new RangeAxis(dataset.getRangeLabel(), rangeAxisId);
rangeAxis.setPlot(plot);
rangeAxis.setView(view);
rangeAxis.setAxisIndex(i);
id2rangeAxis.put(rangeAxisId, rangeAxis);
}
if (!localRangeAxisIds.contains(rangeAxisId)) {
if (axisPanel == null || plot.isMultiaxis()) {
axisPanel = new RangeAxisPanel();
axisPanel.setValueAxis(rangeAxis);
compositePanel.add(axisPanel);
}
rangeAxis.setAxisPanel(axisPanel);
double tickLabelHeight = Math.min(axisPanel.getMaxLabelHeight(), 12);
rangeAxis.setTickLabelHeight(tickLabelHeight);
localRangeAxisIds.add(rangeAxisId);
double h = getBounds().height;
double rangeAxisHeight = h < 20 ? view.getHeight()*0.75 : h;
rangeAxisHeight -= rangeAxisHeight > tickLabelHeight*2 ? tickLabelHeight : 0;
rangeAxis.setRangeAxisHeight(rangeAxisHeight);
}
rangeAxis.adjustAbsRange(dataset);
rangeAxes.add(rangeAxis);
}
clearDrawCaches();
return rangeAxes.toArray(new RangeAxis[rangeAxes.size()]);