title: Combine two x-y plots using SwiftUI and the Charts Library
body: <p>I am working with SwiftUI and the Charts Library (ie import Charts)</p>
  <p>All OK with producing a singe line.
  However I want to plot 2 separate lines on the chart</p>
  <p>But cannot work out how to do this</p>
  <p>I call the struct with the following line:</p>
  <pre><code>myLineChartSwiftUI(myXminny: self.$myXminny, myXmaxy: self.$myXmaxy)
  </code></pre>
  <p>I have added the 2nd line setup (ie dataPoints2, set2, color2 etc )</p>
  <p>How the hell do I combine the 2 lines to return then for the plot?</p>
  <p>Help would be very much appreciated</p>
  <p>My first swiftUI and 1st Charts program:</p>
  <pre><code>struct myLineChartSwiftUI : UIViewRepresentable
  {
      @Binding var myXminny : Double
      @Binding var myXmaxy  : Double
  
      let lineChart = LineChartView()
  
      func makeUIView(context: UIViewRepresentableContext&lt;myLineChartSwiftUI&gt;) -&gt; LineChartView {
          setUpChart()
          return lineChart
      }
  
      func updateUIView(_ uiView: LineChartView, context: UIViewRepresentableContext&lt;myLineChartSwiftUI&gt;) {
  
      }
  
      func setUpChart() {
          
          let dataSets = [getLineChartDataSet()]
          let data = LineChartData(dataSets: dataSets)
          lineChart.data = data
      }
  
      func getChartDataPoints(sessions: [Double], accuracy: [Double]) -&gt; [ChartDataEntry] {
          var dataPoints: [ChartDataEntry] = []
          for count in (0..&lt;sessions.count) {
              dataPoints.append(ChartDataEntry.init(x: Double(sessions[count]), y: accuracy[count]))
          }
          return dataPoints
      }
  
      func getLineChartDataSet() -&gt; LineChartDataSet {
  
          let dataPoints = getChartDataPoints(sessions: [myXminny,myXmaxy], accuracy: [myXminny,myXmaxy]) 
          let set = LineChartDataSet(entries: dataPoints, label: &quot;DataSet&quot;)
          set.lineWidth = 2
          set.drawValuesEnabled = false
          set.drawCirclesEnabled = false
          //set.circleRadius = 4
          let color = ChartColorTemplates.vordiplom()[4]
          set.setColor(color)
  
          let dataPoints2 = getChartDataPoints(sessions: [myXminny/2,myXmaxy/2], accuracy: [myXminny/2,myXmaxy/2])
          let set2 = LineChartDataSet(entries: dataPoints2, label: &quot;DataSet2&quot;)
          set2.lineWidth = 2
          set2.drawValuesEnabled = false
          set2.drawCirclesEnabled = false
          let color2 = ChartColorTemplates.vordiplom()[4]
          set2.setColor(color2)
          
          let data = LineChartData(dataSets: [set, set2])
  
          return set
      }
  }
  </code></pre>