in google visualization i have a ChartWrapper:
table = new google.visualization.ChartWrapper({
'chartType': 'Table',
'containerId': 'table_div',
'options': {
'allowHtml': true,
},
});
I'd like to export to csv the data visualized in the table (after make some filter) So i get the Data Table:
var dataTableTmp = table.getDataTable();
Now if i try to remove a column from the dataTable:
dataTableTmp.removeColumn(0);
i get the following error:
Uncaught TypeError: undefined is not a function
What is the problem?
in google visualization i have a ChartWrapper:
table = new google.visualization.ChartWrapper({
'chartType': 'Table',
'containerId': 'table_div',
'options': {
'allowHtml': true,
},
});
I'd like to export to csv the data visualized in the table (after make some filter) So i get the Data Table:
var dataTableTmp = table.getDataTable();
Now if i try to remove a column from the dataTable:
dataTableTmp.removeColumn(0);
i get the following error:
Uncaught TypeError: undefined is not a function
What is the problem?
Share Improve this question asked Jul 23, 2014 at 14:24 TomTom 4,10725 gold badges72 silver badges107 bronze badges 1- What is the purpose of removing the column? There are a couple of different approaches you can take, and which one you use depends largely on what you want to do with the data afterwards. – asgallant Commented Jul 24, 2014 at 0:08
1 Answer
Reset to default 8The getDataTable
method returns whatever object is passed to the ChartWrapper's dataTable
parameter. In the case of Dashboards, the ChartWrapper actually receives a DataView, not a DataTable. There are a couple of different approaches you can take to "remove" the column, depending on what you want to acplish by removing it.
If all you need to do is read from the data, ignoring the first column, the simplest solution is to iterate over the columns starting at index 1, not 0.
You can also create a new DataView based on the existing data and restrict the columns in the view, eg:
var view = new google.visualization.DataView(dataTableTmp);
view.setColumns([1, 2, 3, 4 /* etc... */]);
You can also convert the DataView to an actual DataTable, and then remove the column from the DataTable:
var dt = dataTableTmp.toDataTable();
dt.removeColumn(0);
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745119234a4612315.html
评论列表(0条)