Package com.illumon.iris.console.utils
Class PivotWidgetBuilder
java.lang.Object
com.illumon.iris.console.utils.PivotWidgetBuilder
Helper class to build a Pivot Widget and set all of its options.
Example Usage:
pw = PivotWidgetBuilder.pivot(t, "rowCol", "titleCol", "valueCol").sum().across().down().show()
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
A helper to define an specific rowColumn order -
Constructor Summary
ConstructorsConstructorDescriptionPivotWidgetBuilder
(Table tableToPivot, String row, String columnTitleColumn, String valueColumn) Creates a Pivot Widget Builder. -
Method Summary
Modifier and TypeMethodDescriptionacross()
Shorthand to turn on across aggregation.across
(boolean value) Indicates whether or not to aggregate across.addFilterColumns
(String... filterColumns) Adds one or more filter columns to the Pivot Widget.Adds one or more rows to the Pivot Widget.addValueColumns
(String... valueColumns) Adds one or more value columns to the Pivot Widget.autoFilterFetchSize
(String filterColumn, int initialFetchSize) Defines an initial fetch size for a single autoFilter screen.avg()
Sets the aggregation to AVERAGE.Sets totals (both down and across) to be a average.If a heatmap is being displayed, this will color the row columns as well.down()
Shorthand to turn on down aggregation.down
(boolean value) Indicates whether or not to aggregate down.first()
Sets the aggregation to FIRST.heatMap()
Display a heat map with default coloring.heatMap
(boolean value) Indicates whether or not to display a heat map.Ifvalue
is true, display a heat map with the given colors.Display a heat map with the given colors.last()
Sets the aggregation to LAST.static PivotWidgetBuilder
Starts a Pivot Widget Builder.requireFilteredColumns
(String... requiredFilterColumns) Adds one or more filter columns to the Pivot Widget and requires these columns to be filtered before calculating the Pivot Widget.setColorFormat
(Function<Object, Object> colorFormat) Sets the Color Format for the Pivot Widget.setColorFormat
(Function<Object, Object> colorFormat, String... formatColumns) Sets the Color Format for the Pivot Widget on a per-column basis.setColumnNameTransform
(Function<Object, Object> columnNameTransform) Sets a transform to rename columns in the Pivot Widget.setDecimalFormat
(String value, PivotRole role, String format) Set the decimal format for the role and pivoted value.setIntegerFormat
(String value, PivotRole role, String format) setMainDecimalFormat
(String format) Sets the decimal format for the main table.setMainIntegerFormat
(String format) Sets the integer format for the main table.setRowDecimalFormat
(String format) Sets the decimal format for the row tablesetRowIntegerFormat
(String format) Sets the integer format for the row tablesetTotalsDecimalFormat
(String format) Sets the decimal format for the totals tablesetTotalsIntegerFormat
(String format) Sets the integer format for the totals tableshow()
Shows the Pivot Widget.sortColumnsCustom
(Comparable<?>... firstKey) Begin defining the order columns should appear in.Sort Column Titles AscendingSort Column Titles DescendingsortRows()
Sort Rows Ascending based on Key Column(s)Sort Rows Ascending based on Pivot Table Column.Sort Rows Ascending based on Totals ColumnSort Rows Descending based on Totals ColumnsortRowsCustom
(Comparable<?>... firstKey) Begin defining the order rowColumns should appear in.Sort Rows Descending based on Key Column(s)sortRowsDescending
(String columnName) Sort Rows Descending based on Pivot Table Column.sum()
Sets the aggregation to SUM.Sets totals (both down and across) to be an sum.totals
(boolean value) Indicates whether or not display totals.unique()
Sets the aggregation to UNIQUE.
-
Constructor Details
-
PivotWidgetBuilder
@ScriptApi public PivotWidgetBuilder(Table tableToPivot, String row, String columnTitleColumn, String valueColumn) Creates a Pivot Widget Builder.- Parameters:
tableToPivot
- the table to pivotrow
- a key column for the rows, more can be added usingaddRows(String...)
columnTitleColumn
- the column used as a title for each columnvalueColumn
- a column containing values of interest, more can be added usingaddValueColumns(String...)
-
-
Method Details
-
pivot
@ScriptApi public static PivotWidgetBuilder pivot(Table tableToPivot, String row, String columnTitleColumn, String unitColumn) Starts a Pivot Widget Builder.- Parameters:
tableToPivot
- the table to pivotrow
- a key column for the rows, more can be added usingaddRows(String...)
columnTitleColumn
- the column used as a title for each columnunitColumn
- a column containing values of interest, more can be added usingaddValueColumns(String...)
-
show
Shows the Pivot Widget.- Returns:
- a LiveWidget containing a Pivot Widget
-
addRows
Adds one or more rows to the Pivot Widget.- Parameters:
rows
- key columns for the rows
-
addValueColumns
Adds one or more value columns to the Pivot Widget.- Parameters:
valueColumns
- columns containing values of interest
-
addFilterColumns
Adds one or more filter columns to the Pivot Widget.- Parameters:
filterColumns
- columns to be used for filtering
-
autoFilterFetchSize
Defines an initial fetch size for a single autoFilter screen.- Parameters:
filterColumn
- the name of the column to which this new initial fetch size should be appliedinitialFetchSize
- the new "default" number of values that should be fetched
-
requireFilteredColumns
Adds one or more filter columns to the Pivot Widget and requires these columns to be filtered before calculating the Pivot Widget. Note that there is no need to calladdFilterColumns(java.lang.String...)
for these columns. They will be automatically added as filter columns.- Parameters:
requiredFilterColumns
- required columns to be used for filtering
-
sum
Sets the aggregation to SUM. Note that only one aggregation can be set. -
avg
Sets the aggregation to AVERAGE. Note that only one aggregation can be set. -
first
Sets the aggregation to FIRST. Note that only one aggregation can be set. -
last
Sets the aggregation to LAST. Note that only one aggregation can be set. -
unique
Sets the aggregation to UNIQUE. Note that only one aggregation can be set. -
across
Indicates whether or not to aggregate across. Defaults to false.- Parameters:
value
- true to aggregate across
-
across
Shorthand to turn on across aggregation. -
down
Indicates whether or not to aggregate down. Defaults to false.- Parameters:
value
- true to aggregate down
-
down
Shorthand to turn on down aggregation. -
totals
Indicates whether or not display totals. Defaults to true.- Parameters:
value
- true to display totals
-
sumTotals
Sets totals (both down and across) to be an sum. -
avgTotals
Sets totals (both down and across) to be a average. -
sortRows
Sort Rows Ascending based on Key Column(s) -
sortRowsDescending
Sort Rows Descending based on Key Column(s) -
sortRows
Sort Rows Ascending based on Pivot Table Column. This is done as a best-effort, since we do not yet know the names of the columns in the main-pivot table. These will not be known until after the table-to-pivot is fetched In the case that the specified columnName does not end up being valid, we will fall back to unsorted- Parameters:
columnName
- the Name of a column in the main pivot-table
-
sortRowsDescending
Sort Rows Descending based on Pivot Table Column. This is done as a best-effort, since we do not yet know the names of the columns in the main-pivot table. These will not be known until after the table-to-pivot is fetched In the case that the specified columnName does not end up being valid, we will fall back to unsorted- Parameters:
columnName
- the Name of a column in the main pivot-table
-
sortRowsByTotals
Sort Rows Ascending based on Totals Column -
sortRowsByTotalsDescending
Sort Rows Descending based on Totals Column -
sortColumnTitles
Sort Column Titles Ascending -
sortColumnTitlesDescending
Sort Column Titles Descending -
heatMap
Display a heat map with default coloring. -
heatMap
Display a heat map with the given colors.- Parameters:
minColor
- foreground color at or below the minimum value of the heat mapmaxColor
- foreground color at or below the maximum value of the heat map
-
heatMap
Indicates whether or not to display a heat map. Defaults to false. Ifvalue
is true, this heat map will the use default colors.- Parameters:
value
- true to display a heat map
-
heatMap
Ifvalue
is true, display a heat map with the given colors. Ifvalue
is false, do not display a heat map.- Parameters:
value
- true to display a heat mapminColor
- foreground color at or below the minimum value of the heat mapmaxColor
- foreground color at or below the maximum value of the heat map
-
setMainDecimalFormat
Sets the decimal format for the main table.- Parameters:
format
- the decimal format for the main table
-
setRowDecimalFormat
Sets the decimal format for the row table- Parameters:
format
- the decimal format for the row table
-
setTotalsDecimalFormat
Sets the decimal format for the totals table- Parameters:
format
- the decimal format for the totals table
-
setMainIntegerFormat
Sets the integer format for the main table.- Parameters:
format
- the integer format for the main table
-
setRowIntegerFormat
Sets the integer format for the row table- Parameters:
format
- the integer format for the row table
-
setTotalsIntegerFormat
Sets the integer format for the totals table- Parameters:
format
- the integer format for the totals table
-
setDecimalFormat
@ScriptApi public PivotWidgetBuilder setDecimalFormat(@NotNull String value, @NotNull PivotRole role, @NotNull String format) Set the decimal format for the role and pivoted value.- Parameters:
value
- The value this format applies torole
- thePivotRole
the format applies toformat
- the format string- Returns:
- this builder
-
setIntegerFormat
-
setColumnNameTransform
@ScriptApi public PivotWidgetBuilder setColumnNameTransform(Function<Object, Object> columnNameTransform) Sets a transform to rename columns in the Pivot Widget.- Parameters:
columnNameTransform
- the column name transform
-
setColorFormat
Sets the Color Format for the Pivot Widget.- Parameters:
colorFormat
- the color format
-
setColorFormat
@ScriptApi public PivotWidgetBuilder setColorFormat(Function<Object, Object> colorFormat, String... formatColumns) Sets the Color Format for the Pivot Widget on a per-column basis.- Parameters:
colorFormat
- the color formatformatColumns
- the name(s) of the column(s) for which the format should apply
-
colorRowColumns
If a heatmap is being displayed, this will color the row columns as well. -
sortRowsCustom
Begin defining the order rowColumns should appear in. Unspecified keys encountered will appear after all items specified here.- Parameters:
firstKey
- The set of objects that define the first rowColumn (for example "AAPL", "2020-01-32")- Returns:
- a ColumnOrderer to continue the ordering. Users must invoke
PivotWidgetBuilder.ColumnOrderer.done()
to continue specifying pivot properties.
-
sortColumnsCustom
Begin defining the order columns should appear in. Unspecified keys encountered will appear after all items specified here.- Parameters:
firstKey
- The set of objects that define the first column (for example "AAPL", "2020-01-32")- Returns:
- a ColumnOrderer to continue the ordering. Users must invoke
PivotWidgetBuilder.ColumnOrderer.done()
to continue specifying pivot properties.
-