OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Error when trying to use addRange in Embedded Line Chart Builder

  • Thread starter Thread starter Tpk43
  • Start date Start date
T

Tpk43

Guest
I am posting it here after trying multiple solutions.

My Data in Gsheet looks like

enter image description here

I am trying to draw an line Chart my code is below

Code:
var c_data = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("chart_data");
var curr_date = Utilities.formatDate(new Date(), "GMT+1", "dd/MM/yyyy");
//Inserting New Sheet here
var new_ss = SpreadsheetApp.getActiveSpreadsheet().insertSheet('Numbers - ' + curr_date);
//Get data Range for chart here
var n_data = c_data.getRange("I2:J").getValues(); // I logged and checked here its a 2D array

var chart_d = new_ss.newChart().asLineChart().addRange(n_data)
  .setTitle("Help on the Error :(")
  .setXAxisTitle('Numbers')
  .setYAxisTitle('Months')
  .setPosition(5,5,0,0)
  .setOption('width', 700)
  .setOption('height', 200)
  .build();

I am getting the Error

Error
Exception: The parameters (number[]) don't match the method signature for SpreadsheetApp.EmbeddedLineChartBuilder.addRange.

<p>I am posting it here after trying multiple solutions.</p>
<p>My Data in Gsheet looks like</p>
<p><a href="https://i.sstatic.net/OlIvMgc1.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/OlIvMgc1.png" alt="enter image description here" /></a></p>
<p>I am trying to draw an line Chart my code is below</p>
<pre><code>var c_data = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("chart_data");
var curr_date = Utilities.formatDate(new Date(), "GMT+1", "dd/MM/yyyy");
//Inserting New Sheet here
var new_ss = SpreadsheetApp.getActiveSpreadsheet().insertSheet('Numbers - ' + curr_date);
//Get data Range for chart here
var n_data = c_data.getRange("I2:J").getValues(); // I logged and checked here its a 2D array

var chart_d = new_ss.newChart().asLineChart().addRange(n_data)
.setTitle("Help on the Error :(")
.setXAxisTitle('Numbers')
.setYAxisTitle('Months')
.setPosition(5,5,0,0)
.setOption('width', 700)
.setOption('height', 200)
.build();

</code></pre>
<p>I am getting the Error</p>
<blockquote>
<p>Error<br />
Exception: The parameters (number[]) don't match the method signature for SpreadsheetApp.EmbeddedLineChartBuilder.addRange.</p>
</blockquote>
 

Latest posts

Top