Hey All,
Short term solution for the .clone() and .toDataTable() issue with the live version of the Visualization.
Current Issue:
using datatable.clone() or dataview.toDataTable() will cause issues on the 29-31st of each month for dates with less days than the current date (i.e. February 2015 will have problems on 29 & 30 June 2016).
Sounds like the new version of Google Visualization will resolve this issue but this is not the live version today and probably not tomorrow either.
Datatable.Clone() workaround:
prev: newDatatable = oldDatatable.clone();
now: newDatatable = cloneDataTable(oldDatatable);
DataView.ToDatatable() workaround:
prev: newDatatable = oldDataView.toDatatable();
now: newDatatable = convertDataViewToDataTable(oldDataView);
Functions:
function cloneDataTable(dataTable) {
var newDataTable = dataTable.clone();
for (var c = 0; c < dataTable.getNumberOfColumns(); c++) {
if (dataTable.getColumnType(c) == 'datetime' || dataTable.getColumnType(c) == 'date' ) {
for (var r = 0; r < dataTable.getNumberOfRows() ; r++) {
newDataTable.setValue(r, c, dataTable.getValue(r, c));
}
}
}
return newDataTable;
}
function convertDataViewToDataTable(dataView) {
var newDataTable = dataView.toDataTable();
for (var c = 0; c < dataView.getNumberOfColumns(); c++) {
if (dataView.getColumnType(c) == 'datetime' || dataView.getColumnType(c) == 'date' ) {
for (var r = 0; r < dataView.getNumberOfRows(); r++) {
newDataTable.setValue(r, c, dataView.getValue(r, c));
}
}
}
return newDataTable;
}
Hope this helps...
J