Package com.illumon.iris.console.utils
Class PivotWidgetBuilder
java.lang.Object
com.illumon.iris.console.utils.PivotWidgetBuilder
@ScriptApi public class PivotWidgetBuilder extends Object
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 Classes Modifier and Type Class Description class
PivotWidgetBuilder.ColumnOrderer
A helper to define an specific rowColumn order -
Constructor Summary
Constructors Constructor Description PivotWidgetBuilder(Table tableToPivot, String row, String columnTitleColumn, String valueColumn)
Creates a Pivot Widget Builder. -
Method Summary
Modifier and Type Method Description PivotWidgetBuilder
across()
Shorthand to turn on across aggregation.PivotWidgetBuilder
across(boolean value)
Indicates whether or not to aggregate across.PivotWidgetBuilder
addFilterColumns(String... filterColumns)
Adds one or more filter columns to the Pivot Widget.PivotWidgetBuilder
addRows(String... rows)
Adds one or more rows to the Pivot Widget.PivotWidgetBuilder
addValueColumns(String... valueColumns)
Adds one or more value columns to the Pivot Widget.PivotWidgetBuilder
autoFilterFetchSize(String filterColumn, int initialFetchSize)
Defines an initial fetch size for a single autoFilter screen.PivotWidgetBuilder
avg()
Sets the aggregation to AVERAGE.PivotWidgetBuilder
avgTotals()
Sets totals (both down and across) to be a average.PivotWidgetBuilder
colorRowColumns()
If a heatmap is being displayed, this will color the row columns as well.PivotWidgetBuilder
down()
Shorthand to turn on down aggregation.PivotWidgetBuilder
down(boolean value)
Indicates whether or not to aggregate down.PivotWidgetBuilder
first()
Sets the aggregation to FIRST.PivotWidgetBuilder
heatMap()
Display a heat map with default coloring.PivotWidgetBuilder
heatMap(boolean value)
Indicates whether or not to display a heat map.PivotWidgetBuilder
heatMap(boolean value, Color minColor, Color maxColor)
Ifvalue
is true, display a heat map with the given colors.PivotWidgetBuilder
heatMap(Color minColor, Color maxColor)
Display a heat map with the given colors.PivotWidgetBuilder
last()
Sets the aggregation to LAST.static PivotWidgetBuilder
pivot(Table tableToPivot, String row, String columnTitleColumn, String unitColumn)
Starts a Pivot Widget Builder.PivotWidgetBuilder
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.PivotWidgetBuilder
setColorFormat(Function<Object,Object> colorFormat)
Sets the Color Format for the Pivot Widget.PivotWidgetBuilder
setColorFormat(Function<Object,Object> colorFormat, String... formatColumns)
Sets the Color Format for the Pivot Widget on a per-column basis.PivotWidgetBuilder
setColumnNameTransform(Function<Object,Object> columnNameTransform)
Sets a transform to rename columns in the Pivot Widget.PivotWidgetBuilder
setDecimalFormat(String value, PivotRole role, String format)
Set the decimal format for the role and pivoted value.PivotWidgetBuilder
setIntegerFormat(String value, PivotRole role, String format)
PivotWidgetBuilder
setMainDecimalFormat(String format)
Sets the decimal format for the main table.PivotWidgetBuilder
setMainIntegerFormat(String format)
Sets the integer format for the main table.PivotWidgetBuilder
setRowDecimalFormat(String format)
Sets the decimal format for the row tablePivotWidgetBuilder
setRowIntegerFormat(String format)
Sets the integer format for the row tablePivotWidgetBuilder
setTotalsDecimalFormat(String format)
Sets the decimal format for the totals tablePivotWidgetBuilder
setTotalsIntegerFormat(String format)
Sets the integer format for the totals tableLiveWidget<LivePivotWidget>
show()
Shows the Pivot Widget.PivotWidgetBuilder.ColumnOrderer
sortColumnsCustom(Comparable<?>... firstKey)
Begin defining the order columns should appear in.PivotWidgetBuilder
sortColumnTitles()
Sort Column Titles AscendingPivotWidgetBuilder
sortColumnTitlesDescending()
Sort Column Titles DescendingPivotWidgetBuilder
sortRows()
Sort Rows Ascending based on Key Column(s)PivotWidgetBuilder
sortRows(String columnName)
Sort Rows Ascending based on Pivot Table Column.PivotWidgetBuilder
sortRowsByTotals()
Sort Rows Ascending based on Totals ColumnPivotWidgetBuilder
sortRowsByTotalsDescending()
Sort Rows Descending based on Totals ColumnPivotWidgetBuilder.ColumnOrderer
sortRowsCustom(Comparable<?>... firstKey)
Begin defining the order rowColumns should appear in.PivotWidgetBuilder
sortRowsDescending()
Sort Rows Descending based on Key Column(s)PivotWidgetBuilder
sortRowsDescending(String columnName)
Sort Rows Descending based on Pivot Table Column.PivotWidgetBuilder
sum()
Sets the aggregation to SUM.PivotWidgetBuilder
sumTotals()
Sets totals (both down and across) to be an sum.PivotWidgetBuilder
totals(boolean value)
Indicates whether or not display totals.PivotWidgetBuilder
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
@ScriptApi public PivotWidgetBuilder autoFilterFetchSize(String filterColumn, int initialFetchSize)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.
-