A builder for number range filter controls.
A number range filter is a slider with two thumbs that lets the user select ranges of numeric values. Given a column of type number and matching options, this control will filter out the rows that don't match the range that was selected.
This example creates a table chart bound to a number range filter:
function doGet() { var app = UiApp.createApplication(); // Get sample data from a spreadsheet. var dataSourceUrl = 'https://docs.google.com/spreadsheet/tq?range=A1%3AF' + '&key=0Aq4s9w_HxMs7dHpfX05JdmVSb1FpT21sbXd4NVE3UEE&gid=4&headers=-1'; var data = SpreadsheetApp.openByUrl(dataSourceUrl).getSheetByName('US_GDP').getRange("A1:F"); var chart = Charts.newTableChart() .setDimensions(600, 500) .build(); var numberRangeFilter = Charts.newNumberRangeFilter() .setFilterColumnLabel("Year") .setShowRangeValues(true) .setLabel("Restrict year range") .build(); var panel = app.createVerticalPanel().setSpacing(10); panel.add(numberRangeFilter).add(chart); // Create a new dashboard panel to bind the filter and chart together. var dashboard = Charts.newDashboardPanel() .setDataTable(data) .bind(numberRangeFilter, chart) .build(); dashboard.add(panel); app.add(dashboard); return app; }For more details, see the Gviz documentation
Methods
Method | Return type | Brief description |
---|---|---|
build() | Control | Builds a control. |
setDataTable(tableBuilder) | NumberRangeFilterBuilder | Sets the data table to use for the control using a DataTableBuilder. |
setDataTable(table) | NumberRangeFilterBuilder | Sets the control data table, which will be the control's underlying data model. |
setFilterColumnIndex(columnIndex) | NumberRangeFilterBuilder | Sets the index of the data table column to filter on. |
setFilterColumnLabel(columnLabel) | NumberRangeFilterBuilder | Sets the label of the data table column to filter on. |
setLabel(label) | NumberRangeFilterBuilder | Sets the label to display next to the slider. |
setLabelSeparator(labelSeparator) | NumberRangeFilterBuilder | Sets a separator string appended to the label, to visually separate the label from the category picker. |
setLabelStacking(orientation) | NumberRangeFilterBuilder | Sets whether the label should display above (vertical stacking) or beside (horizontal stacking) the input field. |
setMaxValue(maxValue) | NumberRangeFilterBuilder | Sets the maximum allowed value for the range lower extent. |
setMinValue(minValue) | NumberRangeFilterBuilder | Sets the minimum allowed value for the range lower extent. |
setOrientation(orientation) | NumberRangeFilterBuilder | Sets the slider orientation. |
setShowRangeValues(showRangeValues) | NumberRangeFilterBuilder | Sets whether to have labels next to the slider displaying extents of the selected range. |
setTicks(ticks) | NumberRangeFilterBuilder | Sets the number of ticks (fixed positions in a range bar) a number range filter slider thumbs can fall in. |
Detailed documentation
build()
setDataTable(tableBuilder)
Sets the data table to use for the control using a DataTableBuilder.
This is a convenience method for setting the data table without needing to call build()
.
Parameters
Name | Type | Description |
---|---|---|
tableBuilder | DataTableBuilder | a data table builder. A new data table will be created instantly as part of this call, so any further updates to the builder won't be reflected in the control. |
Return
NumberRangeFilterBuilder
— this builder, useful for chaining
setDataTable(table)
Sets the control data table, which will be the control's underlying data model.
Parameters
Name | Type | Description |
---|---|---|
table | DataTableSource | the data table to use for the control |
Return
NumberRangeFilterBuilder
— this builder, useful for chaining
setFilterColumnIndex(columnIndex)
Sets the index of the data table column to filter on.
The values of that column will determine whether or not each row should be filtered. It is
mandatory to set either this or the column label using setFilterColumnLabel(columnLabel)
.
Parameters
Name | Type | Description |
---|---|---|
columnIndex | Integer | the index of the data table column the filter should operate upon |
Return
NumberRangeFilterBuilder
— this builder, useful for chaining
setFilterColumnLabel(columnLabel)
Sets the label of the data table column to filter on.
The values of that column will determine whether or not each row should be filtered. It is
mandatory to set either this or a column index using setFilterColumnIndex(columnIndex)
.
Parameters
Name | Type | Description |
---|---|---|
columnLabel | String | the label of the column to filter on |
Return
NumberRangeFilterBuilder
— this builder, useful for chaining
setLabel(label)
Sets the label to display next to the slider.
If unspecified, the label of the column the control operates on will be used.
Parameters
Name | Type | Description |
---|---|---|
label | String | the label to display next to the slider |
Return
NumberRangeFilterBuilder
— this builder, useful for chaining
setLabelSeparator(labelSeparator)
Sets a separator string appended to the label, to visually separate the label from the category picker.
Parameters
Name | Type | Description |
---|---|---|
labelSeparator | String | the string to use to separate the label from the category picker |
Return
NumberRangeFilterBuilder
— this builder, useful for chaining
setLabelStacking(orientation)
Sets whether the label should display above (vertical stacking) or beside (horizontal stacking) the input field.
Parameters
Name | Type | Description |
---|---|---|
orientation | Orientation | the orientation of the stacking |
Return
NumberRangeFilterBuilder
— this builder, useful for chaining
setMaxValue(maxValue)
Sets the maximum allowed value for the range lower extent. If undefined, the value will be inferred from the contents of the DataTable managed by the control.
// Builds a number range filter and sets the maximum value to 100. var numberRangeFilter = Charts.newNumberRangeFilter() .setFilterColumnLabel("Col2") .setMaxValue(100) .build();
Parameters
Name | Type | Description |
---|---|---|
maxValue | Integer | the maximum value of the slider |
Return
NumberRangeFilterBuilder
— this builder, useful for chaining
setMinValue(minValue)
Sets the minimum allowed value for the range lower extent. If undefined, the value will be inferred from the contents of the DataTable managed by the control.
// Builds a number range filter and sets the minimum value to 10. var numberRangeFilter = Charts.newNumberRangeFilter() .setFilterColumnLabel("Col2") .setMinValue(10) .build();
Parameters
Name | Type | Description |
---|---|---|
minValue | Integer | the minimum value of the slider |
Return
NumberRangeFilterBuilder
— this builder, useful for chaining
setOrientation(orientation)
Sets the slider orientation.
// Builds a number range filter and sets it to have a horizontal orientation. var numberRangeFilter = Charts.newNumberRangeFilter() .setFilterColumnLabel("Col2") .setOrientation(Charts.Orientation.HORIZONTAL) .build();
Parameters
Name | Type | Description |
---|---|---|
orientation | Orientation | the slider orientation |
Return
NumberRangeFilterBuilder
— this builder, useful for chaining
See also
setShowRangeValues(showRangeValues)
Sets whether to have labels next to the slider displaying extents of the selected range.
// Builds a number range filter and enables showing of the number range values. var numberRangeFilter = Charts.newNumberRangeFilter() .setFilterColumnLabel("Col2") .setShowRangeValues(true) .build();
Parameters
Name | Type | Description |
---|---|---|
showRangeValues | Boolean | if true, enables showing of labels next to the slider |
Return
NumberRangeFilterBuilder
— this builder, useful for chaining
setTicks(ticks)
Sets the number of ticks (fixed positions in a range bar) a number range filter slider thumbs can fall in.
// Builds a number range filter and sets the number of ticks for the range to 10. var numberRangeFilter = Charts.newNumberRangeFilter() .setFilterColumnLabel("Col2") .setTicks(10) .build();
Parameters
Name | Type | Description |
---|---|---|
ticks | Integer | the number of ticks on the slider |
Return
NumberRangeFilterBuilder
— this builder, useful for chaining