When you call:

data.removeColumn(0);

column 0 (the date strings) is removed, and all of the other columns shift 
down 1 index, so the new date column takes the index 0 position.

On Wednesday, April 9, 2014 7:43:28 PM UTC-4, cyb wrote:
>
> HI,
>
> but if i do this:
>
> ou cannot overwrite the contents of a column with a different data type.  
>> You could insert a new column, fill it with dates, and then delete the old 
>> column:
>>
>> data.insertColumn(1, 'date', 'date');
>> for (var i = 0; i < data.getNumberOfRows(); i++) {
>>     var dateString = data.getValue(row, 0).toString();
>>     var year = dateString.substring(0, 4);
>>     var month = dateString.substring(4, 2); // javascript uses 0-indexed 
>> months (ie, January is 0 not 1), so you may need to subtract 1 from this if 
>> you haven't already accounted for it
>>     var day = dateString.substring(6, 2);
>>     data.setValue(1, i, new Date(year, month, day));
>> }
>> data.removeColumn(0);
>>
>> You can then format the date column with a DateFormatter.
>>
>
> then the new Colum is on index 1 ? but the index must be the same, can i 
> remove the old column for example 0 and set the new date colum also to 
> column 0 ? 
>

-- 
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 http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.

Reply via email to