Google Apps Script

Class NumberRangeFilterBuilder

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

MethodReturn typeBrief description
build()ControlBuilds a control.
setDataTable(tableBuilder)NumberRangeFilterBuilderSets the data table to use for the control using a DataTableBuilder.
setDataTable(table)NumberRangeFilterBuilderSets the control data table, which will be the control's underlying data model.
setFilterColumnIndex(columnIndex)NumberRangeFilterBuilderSets the index of the data table column to filter on.
setFilterColumnLabel(columnLabel)NumberRangeFilterBuilderSets the label of the data table column to filter on.
setLabel(label)NumberRangeFilterBuilderSets the label to display next to the slider.
setLabelSeparator(labelSeparator)NumberRangeFilterBuilderSets a separator string appended to the label, to visually separate the label from the category picker.
setLabelStacking(orientation)NumberRangeFilterBuilderSets whether the label should display above (vertical stacking) or beside (horizontal stacking) the input field.
setMaxValue(maxValue)NumberRangeFilterBuilderSets the maximum allowed value for the range lower extent.
setMinValue(minValue)NumberRangeFilterBuilderSets the minimum allowed value for the range lower extent.
setOrientation(orientation)NumberRangeFilterBuilderSets the slider orientation.
setShowRangeValues(showRangeValues)NumberRangeFilterBuilderSets whether to have labels next to the slider displaying extents of the selected range.
setTicks(ticks)NumberRangeFilterBuilderSets the number of ticks (fixed positions in a range bar) a number range filter slider thumbs can fall in.

Detailed documentation

build()

Builds a control.

Return

Control — a control object, that can be used as a UI element


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

NameTypeDescription
tableBuilderDataTableBuildera 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

NameTypeDescription
tableDataTableSourcethe 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

NameTypeDescription
columnIndexIntegerthe 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

NameTypeDescription
columnLabelStringthe 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

NameTypeDescription
labelStringthe 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

NameTypeDescription
labelSeparatorStringthe 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

NameTypeDescription
orientationOrientationthe 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

NameTypeDescription
maxValueIntegerthe 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

NameTypeDescription
minValueIntegerthe 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

NameTypeDescription
orientationOrientationthe 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

NameTypeDescription
showRangeValuesBooleanif 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

NameTypeDescription
ticksIntegerthe number of ticks on the slider

Return

NumberRangeFilterBuilder — this builder, useful for chaining

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.