You can create DataTablewithout any roles, and then create DataViewone that assigns roles to columns in the view. The documentation shows how to do this here :
DataView.setColumns Method
. . DataView.setColumns() .
DataView.setColumns() , :
setColumns(columnIndexes)
- columnIndexes - / ( ): . . , sourceColumn.
- . " " . :
- calc [function] - , , . - func (dataTable, ), dataTable DataTable, - . , .
- type [string] - JavaScript, calc.
- label [, ] - . , .
- id [, ] - , .
- sourceColumn - [, ] ; , calc type.
,
. - properties [, ] - , . ,
. - role [, ] - , . , .
, №3, , :
dataView.setColumns([0, 1, {sourceColumn: 2, role: 'interval'}]);
0 1 , , 2 .
, . :
function drawVisualization() {
var data = google.visualization.arrayToDataTable([
['Year', 'Austria', 'Interval A', 'Interval B'],
['2003', 100, 95, 125],
['2004', 110, 96, 150],
['2005', 120, 97, 175],
['2006', 130, 98, 200],
['2007', 140, 99, 225],
['2008', 150, 100, 250]
]);
var dataView = new google.visualization.DataView(data);
dataView.setColumns([0, 1, {sourceColumn: 2, role: 'interval'}, {sourceColumn: 3, role: 'interval'}]);
new google.visualization.LineChart(document.getElementById('visualization')).
draw(dataView,
{width:600, height:400,
hAxis: {title: "Year"}}
);
}
. dataview, "". . ( ), .