Line Chart addRows reports error of different number of columns

20 views
Skip to first unread message

Jayme Jeffman

unread,
Jun 18, 2017, 1:21:07 PM6/18/17
to Google Visualization API
Hello,

I am not familiar with JASON nor JQuery, so I am using XML data and basic JavaScript.

I am trying to add data to a LineChart using addRows, but I am getting error saying the number of values are different from number of columns:

I have configured the LineChart :

 algLineData = new google.visualization.DataTable();

 algLineData
.addColumn('date'  , 'Dia'       );
 algLineData
.addColumn('number', 'Contrato'  );
 algLineData
.addColumn('number', 'Fora Ponta');
 algLineData
.addColumn('number', 'Total'     ); // 4 columns       

 algLnChart
= new google.visualization.LineChart(document.getElementById('dlinealg'));




I am adding data to arrays:


var dataRows = [];

for(var chd = 0; chd < chdNodes.length; chd++){
 
var ponto = [];
 
// <PTOCRV valor="new Date(2017,4,1),0, 51.3226,51.3226"/> // 4 columns
  ponto
.push(chdNodes.item(chd).getAttribute("valor"));
  dataRows
.push(ponto) ;
}
algLineData.addRows(dataRows);
algLnChart.draw( algLineData, lineOptions);

I do not know why dataRows[] or ponto[] have a number of columns different than 4.


May be I might push to ponto[] each value which are separated by commas.

Thank you very much.

Best regards.

Jayme Jeffman


Jayme Jeffman

unread,
Jun 18, 2017, 1:50:38 PM6/18/17
to Google Visualization API



I have split the data into parts and push them individually into the "ponto" array, but it did not solve the problem.




Jayme Jeffman

unread,
Jun 19, 2017, 2:15:29 PM6/19/17
to Google Visualization API
The original error has vanished, but now I have another, see the image bellow:



How come "new Date(2017,5,1)" is not a valid date value ?

Jayme Jeffman

unread,
Jun 19, 2017, 4:12:47 PM6/19/17
to Google Visualization API
Never mind. I've got it to work.

Thank you very much.
Reply all
Reply to author
Forward
0 new messages