title: Convert bar chart to a grouped bar chart with danielgindi/ios-charts and Swift
body: <p>i have created the simple bar chart with the library at <a href="https://github.com/danielgindi/ios-charts" rel="noreferrer">https://github.com/danielgindi/ios-charts</a> still can't figure out how to make this a grouped bar chart. I've added the units sold array to the chart, but don't know how to get the unitBought array to the chart to make it a grouped chart.please help.</p>
  
  <pre><code>@IBOutlet weak var barChartView: BarChartView!
  
  override func viewDidLoad() {
      super.viewDidLoad()      
      months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
      let unitsSold = [20.0, 4.0, 6.0, 3.0, 12.0, 16.0, 4.0, 18.0, 2.0, 4.0, 5.0, 12.8]
      let unitsBought = [20.0, 4.0, 6.0, 3.0, 12.0, 16.0, 4.0, 18.0, 2.0, 4.0, 5.0, 12.8]
      setChart(months, values: unitsSold)
  }
  
  
  //functions
  func setChart(dataPoints: [String], values: [Double]) {
      barChartView.noDataText = "You need to provide data for the chart."
  
      var dataEntries: [BarChartDataEntry] = []
  
      for i in 0..&lt;dataPoints.count {
          let dataEntry = BarChartDataEntry(value: values[i], xIndex: i)
          dataEntries.append(dataEntry)
      }
  
      let chartDataSet = BarChartDataSet(yVals: dataEntries, label: "Units Sold")
      let chartData = BarChartData(xVals: months, dataSet: chartDataSet)
      barChartView.data = chartData
      barChartView.backgroundColor = UIColor(red: 255/255, green: 255/255, blue: 255/255, alpha: 1)
      barChartView.gridBackgroundColor = UIColor(red: 255/255, green: 255/255, blue: 255/255, alpha: 1)
  
      barChartView.legend.enabled = false
  
      barChartView.leftAxis.drawGridLinesEnabled = false
      barChartView.leftAxis.drawAxisLineEnabled = true
  
      barChartView.rightAxis.drawGridLinesEnabled = false
      barChartView.rightAxis.drawAxisLineEnabled = false
      barChartView.rightAxis.drawLabelsEnabled = false
  
  
      barChartView.xAxis.drawGridLinesEnabled = false
      barChartView.xAxis.drawLabelsEnabled = true
  
  }
  </code></pre>