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
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-visualization-api/436f30ff-cecd-4880-aa8c-669782746dd8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.