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()
  • Constructor Details

    • PivotWidgetBuilder

      @ScriptApi public PivotWidgetBuilder(Table tableToPivot, String row, String columnTitleColumn, String valueColumn)
      Creates a Pivot Widget Builder.
      Parameters:
      tableToPivot - the table to pivot
      row - a key column for the rows, more can be added using addRows(String...)
      columnTitleColumn - the column used as a title for each column
      valueColumn - a column containing values of interest, more can be added using addValueColumns(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 pivot
      row - a key column for the rows, more can be added using addRows(String...)
      columnTitleColumn - the column used as a title for each column
      unitColumn - a column containing values of interest, more can be added using addValueColumns(String...)
    • show

      Shows the Pivot Widget.
      Returns:
      a LiveWidget containing a Pivot Widget
    • addRows

      @ScriptApi public PivotWidgetBuilder addRows(String... rows)
      Adds one or more rows to the Pivot Widget.
      Parameters:
      rows - key columns for the rows
    • addValueColumns

      @ScriptApi public PivotWidgetBuilder addValueColumns(String... valueColumns)
      Adds one or more value columns to the Pivot Widget.
      Parameters:
      valueColumns - columns containing values of interest
    • addFilterColumns

      @ScriptApi public PivotWidgetBuilder addFilterColumns(String... filterColumns)
      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 applied
      initialFetchSize - the new "default" number of values that should be fetched
    • requireFilteredColumns

      @ScriptApi public 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. Note that there is no need to call addFilterColumns(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

      @ScriptApi public PivotWidgetBuilder unique()
      Sets the aggregation to UNIQUE. Note that only one aggregation can be set.
    • across

      @ScriptApi public PivotWidgetBuilder across(boolean value)
      Indicates whether or not to aggregate across. Defaults to false.
      Parameters:
      value - true to aggregate across
    • across

      @ScriptApi public PivotWidgetBuilder across()
      Shorthand to turn on across aggregation.
    • down

      @ScriptApi public PivotWidgetBuilder down(boolean value)
      Indicates whether or not to aggregate down. Defaults to false.
      Parameters:
      value - true to aggregate down
    • down

      Shorthand to turn on down aggregation.
    • totals

      @ScriptApi public PivotWidgetBuilder totals(boolean value)
      Indicates whether or not display totals. Defaults to true.
      Parameters:
      value - true to display totals
    • sumTotals

      @ScriptApi public PivotWidgetBuilder sumTotals()
      Sets totals (both down and across) to be an sum.
    • avgTotals

      @ScriptApi public PivotWidgetBuilder avgTotals()
      Sets totals (both down and across) to be a average.
    • sortRows

      @ScriptApi public PivotWidgetBuilder sortRows()
      Sort Rows Ascending based on Key Column(s)
    • sortRowsDescending

      @ScriptApi public PivotWidgetBuilder sortRowsDescending()
      Sort Rows Descending based on Key Column(s)
    • sortRows

      @ScriptApi public PivotWidgetBuilder sortRows(String columnName)
      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

      @ScriptApi public PivotWidgetBuilder sortRowsDescending(String columnName)
      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

      @ScriptApi public PivotWidgetBuilder sortRowsByTotals()
      Sort Rows Ascending based on Totals Column
    • sortRowsByTotalsDescending

      @ScriptApi public PivotWidgetBuilder sortRowsByTotalsDescending()
      Sort Rows Descending based on Totals Column
    • sortColumnTitles

      @ScriptApi public PivotWidgetBuilder sortColumnTitles()
      Sort Column Titles Ascending
    • sortColumnTitlesDescending

      @ScriptApi public PivotWidgetBuilder sortColumnTitlesDescending()
      Sort Column Titles Descending
    • heatMap

      @ScriptApi public PivotWidgetBuilder heatMap()
      Display a heat map with default coloring.
    • heatMap

      @ScriptApi public PivotWidgetBuilder heatMap(Color minColor, Color maxColor)
      Display a heat map with the given colors.
      Parameters:
      minColor - foreground color at or below the minimum value of the heat map
      maxColor - foreground color at or below the maximum value of the heat map
    • heatMap

      @ScriptApi public PivotWidgetBuilder heatMap(boolean value)
      Indicates whether or not to display a heat map. Defaults to false. If value is true, this heat map will the use default colors.
      Parameters:
      value - true to display a heat map
    • heatMap

      @ScriptApi public PivotWidgetBuilder heatMap(boolean value, Color minColor, Color maxColor)
      If value is true, display a heat map with the given colors. If value is false, do not display a heat map.
      Parameters:
      value - true to display a heat map
      minColor - foreground color at or below the minimum value of the heat map
      maxColor - foreground color at or below the maximum value of the heat map
    • setMainDecimalFormat

      @ScriptApi public PivotWidgetBuilder setMainDecimalFormat(String format)
      Sets the decimal format for the main table.
      Parameters:
      format - the decimal format for the main table
    • setRowDecimalFormat

      @ScriptApi public PivotWidgetBuilder setRowDecimalFormat(String format)
      Sets the decimal format for the row table
      Parameters:
      format - the decimal format for the row table
    • setTotalsDecimalFormat

      @ScriptApi public PivotWidgetBuilder setTotalsDecimalFormat(String format)
      Sets the decimal format for the totals table
      Parameters:
      format - the decimal format for the totals table
    • setMainIntegerFormat

      @ScriptApi public PivotWidgetBuilder setMainIntegerFormat(String format)
      Sets the integer format for the main table.
      Parameters:
      format - the integer format for the main table
    • setRowIntegerFormat

      @ScriptApi public PivotWidgetBuilder setRowIntegerFormat(String format)
      Sets the integer format for the row table
      Parameters:
      format - the integer format for the row table
    • setTotalsIntegerFormat

      @ScriptApi public PivotWidgetBuilder setTotalsIntegerFormat(String format)
      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 to
      role - the PivotRole the format applies to
      format - the format string
      Returns:
      this builder
    • setIntegerFormat

      @ScriptApi public PivotWidgetBuilder setIntegerFormat(String value, PivotRole role, String format)
    • 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

      @ScriptApi public PivotWidgetBuilder setColorFormat(Function<Object,Object> colorFormat)
      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 format
      formatColumns - the name(s) of the column(s) for which the format should apply
    • colorRowColumns

      @ScriptApi public PivotWidgetBuilder colorRowColumns()
      If a heatmap is being displayed, this will color the row columns as well.
    • sortRowsCustom

      @ScriptApi public PivotWidgetBuilder.ColumnOrderer sortRowsCustom(Comparable<?>... firstKey)
      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

      @ScriptApi public PivotWidgetBuilder.ColumnOrderer sortColumnsCustom(Comparable<?>... firstKey)
      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.