/**
  * Adjusts the x min and max bounds of the chart to match the selection region. Has no effect if
  * there is no selected region
  */
 protected void zoomToSelection() {
   if (chart.isRangeSelected()) {
     double[] range = chart.getRangeSelection();
     if (range[0] < range[1]) {
       chart.setXMin(range[0]);
       chart.setXMax(range[1]);
       chart.clearRangeSelection();
       repaint();
     }
   }
 }