Class Facet

All Implemented Interfaces:
ViewComposition, ViewLayoutComposition

public class Facet extends VegaLite implements ViewLayoutComposition
A facet is a trellis plot (or small multiple) of a series of similar plots that displays different subsets of the same data, facilitating comparison across subsets.

The facet channels (facet, row, and column) are encoding channels that serves as macros for a facet specification. Vega-Lite automatically translates this shortcut to use the facet operator.

  • Constructor Details

    • Facet

      public Facet(VegaLite view)
      Constructor.
  • Method Details

    • columns

      public Facet columns(int columns)
      Sets the number of columns to include in the view composition layout.
      Parameters:
      columns - The number of columns to include in the view composition layout.
      Returns:
      this object.
    • facet

      public FacetField facet(String field)
      Returns the field definition for faceting the plot by one field.
      Parameters:
      field - A string defining the name of the field from which to pull a data value. Dots (.) and brackets ([ and ]) can be used to access nested objects (e.g., "field": "foo.bar" and "field": "foo['bar']"). If field names contain dots or brackets but are not nested, you can use \\ to escape dots and brackets (e.g., "a\\.b" and "a\\[0\\]").
      Returns:
      the facet field object.
    • row

      public FacetField row(String field)
      Returns the field definition for the horizontal facet of trellis plots.
      Parameters:
      field - A string defining the name of the field from which to pull a data value. Dots (.) and brackets ([ and ]) can be used to access nested objects (e.g., "field": "foo.bar" and "field": "foo['bar']"). If field names contain dots or brackets but are not nested, you can use \\ to escape dots and brackets (e.g., "a\\.b" and "a\\[0\\]").
      Returns:
      the facet field object.
    • column

      public FacetField column(String field)
      Returns the field definition for the vertical facet of trellis plots.
      Parameters:
      field - A string defining the name of the field from which to pull a data value. Dots (.) and brackets ([ and ]) can be used to access nested objects (e.g., "field": "foo.bar" and "field": "foo['bar']"). If field names contain dots or brackets but are not nested, you can use \\ to escape dots and brackets (e.g., "a\\.b" and "a\\[0\\]").
      Returns:
      the facet field object.
    • usermeta

      public Facet usermeta(com.fasterxml.jackson.databind.JsonNode metadata)
      Description copied from class: VegaLite
      Optional metadata that will be passed to Vega. This object is completely ignored by Vega and Vega-Lite and can be used for custom metadata.
      Overrides:
      usermeta in class VegaLite
    • usermeta

      public Facet usermeta(Object metadata)
      Description copied from class: VegaLite
      Optional metadata that will be passed to Vega. This object is completely ignored by Vega and Vega-Lite and can be used for custom metadata.
      Overrides:
      usermeta in class VegaLite
    • background

      public Facet background(String color)
      Description copied from class: VegaLite
      Sets the background of the entire view with CSS color property.
      Overrides:
      background in class VegaLite
    • padding

      public Facet padding(int size)
      Description copied from class: VegaLite
      Specifies padding for all sides. The visualization padding, in pixels, is from the edge of the visualization canvas to the data rectangle.
      Overrides:
      padding in class VegaLite
    • padding

      public Facet padding(int left, int top, int right, int bottom)
      Description copied from class: VegaLite
      Specifies padding for each side. The visualization padding, in pixels, is from the edge of the visualization canvas to the data rectangle.
      Overrides:
      padding in class VegaLite
    • autosize

      public Facet autosize()
      Description copied from class: VegaLite
      Sets the overall size of the visualization. The total size of a Vega-Lite visualization may be determined by multiple factors: specified width, height, and padding values, as well as content such as axes, legends, and titles.
      Overrides:
      autosize in class VegaLite
    • autosize

      public Facet autosize(String type, boolean resize, String contains)
      Description copied from class: VegaLite
      Sets the overall size of the visualization. The total size of a Vega-Lite visualization may be determined by multiple factors: specified width, height, and padding values, as well as content such as axes, legends, and titles.
      Overrides:
      autosize in class VegaLite
      Parameters:
      type - The sizing format type. One of "pad", "fit", "fit-x", "fit-y", or "none". See Vega-Lite documentation for descriptions of each.
      resize - A boolean flag indicating if autosize layout should be re-calculated on every view update.
      contains - Determines how size calculation should be performed, one of "content" or "padding". The default setting ("content") interprets the width and height settings as the data rectangle (plotting) dimensions, to which padding is then added. In contrast, the "padding" setting includes the padding within the view size calculations, such that the width and height settings indicate the total intended size of the view.
    • name

      public Facet name(String name)
      Description copied from class: VegaLite
      Sets the name of the visualization for later reference.
      Overrides:
      name in class VegaLite
    • description

      public Facet description(String description)
      Description copied from class: VegaLite
      Sets the description of this mark for commenting purpose.
      Overrides:
      description in class VegaLite
    • title

      public Facet title(String title)
      Description copied from class: VegaLite
      Sets a descriptive title to a chart.
      Overrides:
      title in class VegaLite
      Parameters:
      title - a descriptive title.
      Returns:
      this object.
    • resolveScale

      public Facet resolveScale(String channel, String resolution)
      Description copied from interface: ViewComposition
      Sets a scale resolution. For scales, resolution can be specified for every channel.
      Specified by:
      resolveScale in interface ViewComposition
      Parameters:
      channel - positional or non-positional channel.
      resolution - "shared" or "independent".
      Returns:
      this object.
    • resolveAxis

      public Facet resolveAxis(String channel, String resolution)
      Description copied from interface: ViewComposition
      Sets an axis resolution.
      Specified by:
      resolveAxis in interface ViewComposition
      Parameters:
      channel - positional channel: "x" or "y".
      resolution - "shared" or "independent".
      Returns:
      this object.
    • resolveLegend

      public Facet resolveLegend(String channel, String resolution)
      Description copied from interface: ViewComposition
      Sets a legend resolution.
      Specified by:
      resolveLegend in interface ViewComposition
      Parameters:
      channel - non-positional channel: "color", "opacity", "shape", or "size".
      resolution - "shared" or "independent".
      Returns:
      this object.
    • align

      public Facet align(String strategy)
      Description copied from interface: ViewLayoutComposition
      Sets the alignment to apply to grid rows and columns. The supported string values are "all" (the default), "each", and "none".

      For "none", a flow layout will be used, in which adjacent subviews are simply placed one after the other.

      For "each", subviews will be aligned into a clean grid structure, but each row or column may be of variable size.

      For "all", subviews will be aligned and each row or column will be sized identically based on the maximum observed size. String values for this property will be applied to both grid rows and columns.

      Specified by:
      align in interface ViewLayoutComposition
      Parameters:
      strategy - "all", "each", or "none".
      Returns:
      this object.
    • align

      public Facet align(String row, String column)
      Description copied from interface: ViewLayoutComposition
      Sets different alignments for rows and columns.
      Specified by:
      align in interface ViewLayoutComposition
      Parameters:
      row - alignment for rows.
      column - alignment for columns.
      Returns:
      this object.
    • bounds

      public Facet bounds(String bounds)
      Description copied from interface: ViewLayoutComposition
      Sets the bounds calculation method to use for determining the extent of a sub-plot. One of "full" (the default) or "flush".

      If set to "full", the entire calculated bounds (including axes, title, and legend) will be used.

      If set to "flush", only the specified width and height values for the sub-view will be used. The flush setting can be useful when attempting to place sub-plots without axes or legends into a uniform grid structure.

      Specified by:
      bounds in interface ViewLayoutComposition
      Parameters:
      bounds - "full" or "flush".
      Returns:
      this object.
    • center

      public Facet center(boolean flag)
      Description copied from interface: ViewLayoutComposition
      Sets if subviews should be centered relative to their respective rows or columns.
      Specified by:
      center in interface ViewLayoutComposition
      Parameters:
      flag - a flag indicating if subviews should be centered relative to their respective rows or columns.
      Returns:
      this object.
    • center

      public Facet center(int row, int column)
      Description copied from interface: ViewLayoutComposition
      Sets if subviews should be centered relative to their respective rows or columns.
      Specified by:
      center in interface ViewLayoutComposition
      Parameters:
      row - a flag indicating if subviews should be centered relative to their respective rows.
      column - a flag indicating if subviews should be centered relative to their respective columns.
      Returns:
      this object.
    • spacing

      public Facet spacing(int size)
      Description copied from interface: ViewLayoutComposition
      Sets the spacing in pixels between sub-views of the composition operator.
      Specified by:
      spacing in interface ViewLayoutComposition
      Parameters:
      size - the spacing between sub-views.
      Returns:
      this object.
    • spacing

      public Facet spacing(int row, int column)
      Description copied from interface: ViewLayoutComposition
      Sets different spacing values for rows and columns.
      Specified by:
      spacing in interface ViewLayoutComposition
      Parameters:
      row - the spacing between sub-views.
      column - the spacing between sub-views.
      Returns:
      this object.