title: swift: reload view for displaying new data in chart
body: <p>im using the chart-framework 'Charts', however it has no reload function for the chart with new data. It can only display the chart once with loading the viewController. But i want to reload the view/chart with a selection from a table. (the table is in other viewcontroller)</p>
  
  <p>in my case, i have a ViewController with a view inside
  and data are in two arrays: x and y</p>
  
  <pre><code>func setChartData(x: [Double], y: [Double])
  </code></pre>
  
  <p>I tried to call the function but it doesnt display it.
  If the function is called from viewWillAppear()
  the chart is only showing, if i switch to another viewcontroller and switch back</p>
  
  <p>how can i solve this</p>
  
  <p>self.view!.setNeedsDisplay() within the function is not working.</p>
  
  <p>My viewcontroller:</p>
  
  <pre><code>override func viewWillAppear(animated: Bool) {
      setChartData(resultID_statistics, y: resultWeight_statistics)
  
  }
  
  func setChartData(x: [Double], y: [Double])  {
  
      // 1 - creating an array of data entries
      var yVals1 : [ChartDataEntry] = [ChartDataEntry]()
      for var i = 0; i &lt; x.count; i++ {
          yVals1.append(ChartDataEntry(value: y[i], xIndex: i))
      }
  
      // 2 - create a data set with our array
      let set1: LineChartDataSet = LineChartDataSet(yVals: yVals1, label: "First Set")
      set1.axisDependency = .Left // Line will correlate with left axis values
      set1.setColor(UIColor.redColor().colorWithAlphaComponent(0.5)) // our line's opacity is 50%
      set1.setCircleColor(UIColor.redColor()) // our circle will be dark red
      set1.lineWidth = 2.0
      set1.circleRadius = 6.0 // the radius of the node circle
      set1.fillAlpha = 65 / 255.0
      set1.fillColor = UIColor.redColor()
      set1.highlightColor = UIColor.whiteColor()
      set1.drawCircleHoleEnabled = true
  
      //3 - create an array to store our LineChartDataSets
      var dataSets : [LineChartDataSet] = [LineChartDataSet]()
      dataSets.append(set1)
  
      //4 - pass our months in for our x-axis label value along with our dataSets
      let data: LineChartData = LineChartData(xVals: x, dataSets: dataSets)
      data.setValueTextColor(UIColor.whiteColor())
  
      //5 - finally set our data
      self.lineChartView.data = data
  
      data.notifyDataChanged()
      lineChartView.notifyDataSetChanged()
  
  }
  </code></pre>