Also, with arrayToDataTable, you have to replicate the entire DataTable - you can't add new data to an existing DataTable that way.
If you are creating a DataTable from scratch, performance-wise, the fastest method is actually to pass a JSON representation of the DataTable to the DataTable constructor (see here<https://developers.google.com/chart/interactive/docs/reference#DataTable>). Manually defining columns and then using the #addRows method is probably marginally faster than arrayToDataTable, as the API doesn't have to determine the column data types. On Tuesday, August 14, 2012 10:14:23 AM UTC-4, Yolanda Davis wrote: > > I think it depends on what you are doing. If you need to add more > specific column information (such as column id and column type) or need to > use Date/Datetime as a type it may be better to use the addColumn and > addRow methods vs the arrayToDataTable. The arrayToDataTable will interpret > the types based on content, except it cannot detect the Date type nor can > it read Javascript literals in the data. See > https://developers.google.com/chart/interactive/docs/reference#google.visualization.arraytodatatable > > for more info. > > On Tuesday, August 14, 2012 10:06:01 AM UTC-4, API Developer wrote: >> >> Hey guys, >> >> Does anybody know a good way to insert rows into the dataTable? >> Would it be better to just add directly to the data using data.addRows() >> or use a separate matrix and use google.visualization.arrayToDataTable? >> > -- You received this message because you are subscribed to the Google Groups "Google Visualization API" group. To view this discussion on the web visit https://groups.google.com/d/msg/google-visualization-api/-/eQEglAe6l8oJ. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-visualization-api?hl=en.
