title: Set Maximum Zoom for iOS Charts
body: <p>I am new to programming and swift, so I have a question...
  How to set the maximum zoom in iOS charts? tried:</p>
  
  <pre><code> func setBarChart(dataPoints: [String], humidity: [Double], andDays: Int, forTime: String)
  {
      let formato = BarChartFormatter()
      let xaxis  = XAxis()
      var humidityEntry: [BarChartDataEntry] = []
  
      for i in 0..&lt;dataPoints.count
      {
          let dataEntry = BarChartDataEntry(x: Double(i), y: humidity[i])
          humidityEntry.append(dataEntry)
          formato.getNumberOfDays(Double(i), axis: xaxis, andDays: andDays)
      }
  
      xaxis.valueFormatter = formato
      let barChartDataSet3 = BarChartDataSet(values: humidityEntry, label: "Humidity")
      barChartDataSet3.setColor(UIColor.cyan)
      barChartDataSet3.barBorderColor = UIColor.blue
      barChartDataSet3.valueTextColor = UIColor.lightText
  
      barChartView.leftAxis.labelTextColor = UIColor.white
      barChartView.rightAxis.labelTextColor = UIColor.white
      barChartView.leftAxis.labelFont = UIFont.systemFont(ofSize: 11)
      barChartView.rightAxis.labelFont = UIFont.systemFont(ofSize: 11)
      barChartView.scaleYEnabled = false
  //        barChartView.setVisibleXRange(minXRange: 0.1, maxXRange: 1.1)
  //        barChartView.autoScaleMinMaxEnabled = true
  //        barChartView.setVisibleXRange(minXRange: 0.0, maxXRange: 1.0)
  
  
      switch forTime {
      case "6months":
          barChartView.setVisibleXRange(minXRange: 0.0, maxXRange: 3.1)
      case "3months":
          barChartView.setVisibleXRange(minXRange: 0.0, maxXRange: 2.1)
      case "1month":
          barChartView.setVisibleXRange(minXRange: 0.0, maxXRange: 1.5)
      case "7days":
          barChartView.setVisibleXRange(minXRange: 0.0, maxXRange: 1.0)
      default:
          break
      }
  
      if barChartView.xRange &gt;= 1.0 &amp;&amp; barChartView.xRange &lt;= 0
      {
          barChartView.scaleXEnabled = false
      }
  //        barChartView.setVisibleYRangeMaximum(2.0, axis: YAxis.)
  //        barChartView.
  //        if barChartView.scaleX &gt; 1.3
  //        {
  //            barChartView.notifyDataSetChanged()
  //            barChartView.scaleXEnabled = false
  //        }
  //        barChartView.notifyDataSetChanged()
  //        barChartView.scaleXEnabled =
      barChartView.highlightFullBarEnabled = false
  
      var dataSets = [IChartDataSet]()
      dataSets.append(barChartDataSet3)
  
      let lineChartDataTemp = BarChartData(dataSets: dataSets)
      barChartView.legend.font = UIFont.systemFont(ofSize: 14)
      barChartView.legend.textColor = UIColor.white
      barChartView.xAxis.valueFormatter = xaxis.valueFormatter
      barChartView.data = lineChartDataTemp
      barChartView.animate(xAxisDuration: 2.0, yAxisDuration: 2.0)
  
  }
  </code></pre>
  
  <p>But nothing works, sometimes I can zoom to infinite, other time it just shows me weird zoomed-in graphs.</p>