I am working with Google Visualization and receiving Unix Epoch timestamps that I need to convert into an array of strings for use in Google Charts. However, I keep encountering an error:
Type mismatch. Value 2017-8-25 16:23:54,2017-8-25 16:11:54,... does not match type string in column index 0
This is the code snippet causing the issue:
var jsonData = $.ajax({
url: "JSONurl",
type: "GET",
dataType: 'json',
}).done(function (dataJson) {
var mass = [];
for (var i = 0; i < dataJson.length; i++) {
var dateEx = new Date(dataJson[i].dateExecutes);
var year = dateEx.getFullYear();
var month = dateEx.getMonth()+1;
var day = dateEx.getDate();
var hours = dateEx.getHours();
var mins = dateEx.getMinutes();
var secs = dateEx.getSeconds();
var newDate = (year + '-' + month + '-' + day + ' ' + hours + ':' + mins + ':' + secs);
mass[i] = newDate;
}
var data = new google.visualization.DataTable();
data.addColumn('string', mass);
data.addColumn('number', 'passed');
data.addColumn('number', 'failed');
dataJson.forEach(function (row) {
data.addRow([
mass,
row.passed,
row.failed
])
});
I need guidance on how to properly use an array in a column and how to construct cells from an array. Any assistance would be greatly appreciated.