protected function validate_axis($xy, chart_axis $axis, $index = 0) {
        if ($index > 0) {
            $axes = $xy == 'x' ? $this->xaxes : $this->yaxes;
            if (!isset($axes[$index - 1])) {
                throw new coding_exception('Missing ' . $xy . ' axis at index lower than ' . $index);
            }
        }
    }