title: GAS - draw line chart using column A as X and column B as Y
body: <p>In google spreadsheet, I wish to use script to draw a line chart with column A as X and column B as Y.</p>
  
  <p>But below code will draw 2 line. how can I modify it to draw one line just like B = f(A).</p>
  
  <pre><code>function myDemoLineChart() {
     var ss = SpreadsheetApp.getActiveSpreadsheet();
     var sheet = ss.getSheets()[0];
  
    var range = sheet.getRange("A1:B4")
     Logger.log(range)
  
     var lineChart = sheet.newChart()
    .setPosition(6, 1, 0, 0)
    .setChartType(Charts.ChartType.LINE)
    .setOption("title", "Demo")
    .setOption("hAxis.title","X")
    .setOption("vAxis.title", "Y")
    .setOption("curveType","function")
    .setOption("pointSize",10)
    .setOption("width",800)
    .setOption("height",800)
    .addRange(range)
    .build()
    sheet.insertChart(lineChart)
  }
  </code></pre>
  
  <p>Input data as below:</p>
  
  <pre><code>A   B
  3   5
  1   7
  4   2
  2   9
  </code></pre>
  
  <p>Output:
  <a href="https://i.stack.imgur.com/ZTDeT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZTDeT.png" alt="enter image description here"></a></p>