Class VegaLite

java.lang.Object
smile.plot.vega.VegaLite
Direct Known Subclasses:
Concat, Facet, Repeat, View

public class VegaLite extends Object
Vega-Lite specifications are JSON objects that describe a diverse range of interactive visualizations. Besides using a single view specification as a standalone visualization, Vega-Lite also provides operators for composing multiple view specifications into a layered or multi-view specification. These operators include layer, facet, concat, and repeat.
  • Constructor Details

    • VegaLite

      public VegaLite()
      Constructor.
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toPrettyString

      public String toPrettyString()
      Returns the specification in pretty print.
      Returns:
      the specification in pretty print.
    • spec

      public com.fasterxml.jackson.databind.node.ObjectNode spec()
      Returns the Vega-Lite specification.
    • config

      public Config config()
      Returns the configuration object that lists properties of a visualization for creating a consistent theme. This property can only be defined at the top-level of a specification.
    • viewConfig

      public ViewConfig viewConfig()
      Returns the configuration object defining the style of a single view visualization.
    • usermeta

      public VegaLite usermeta(com.fasterxml.jackson.databind.JsonNode metadata)
      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.
    • usermeta

      public VegaLite usermeta(Object metadata)
      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.
    • background

      public VegaLite background(String color)
      Sets the background of the entire view with CSS color property.
    • padding

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

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

      public VegaLite autosize()
      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.
    • autosize

      public VegaLite autosize(String type, boolean resize, String contains)
      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.
      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 VegaLite name(String name)
      Sets the name of the visualization for later reference.
    • description

      public VegaLite description(String description)
      Sets the description of this mark for commenting purpose.
    • title

      public VegaLite title(String title)
      Sets a descriptive title to a chart.
      Parameters:
      title - a descriptive title.
      Returns:
      this object.
    • data

      public Data data()
      Returns the data specification object.
      Returns:
      the data specification object.
    • transform

      public Transform transform()
      Returns the data transformation object. such as filter and new field calculation. Data transformations in Vega-Lite are described via either view-level transforms (the transform property) or field transforms inside encoding (bin, timeUnit, aggregate, sort, and stack).

      When both types of transforms are specified, the view-level transforms are executed first based on the order in the array. Then the inline transforms are executed in this order: bin, timeUnit, aggregate, sort, and stack.

      Returns:
      the data transformation object.
    • show

      public void show() throws IOException, HeadlessException
      Displays the plot with the default browser.
      Throws:
      IOException
      HeadlessException
    • show

      public void show(boolean silent) throws IOException, HeadlessException
      Displays the plot with the default browser.
      Parameters:
      silent - If true, silently swallow any exception.
      Throws:
      IOException
      HeadlessException
    • html

      public String html()
      Returns the HTML of plot specification with Vega Embed.
    • html

      public String html(String lang)
      Returns the HTML of plot specification with Vega Embed.
      Parameters:
      lang - the primary language of document.
      Returns:
      the HTML of plot specification with Vega Embed.
    • iframe

      public String iframe()
      Returns the HTML wrapped in an iframe to render in notebooks.
    • iframe

      public String iframe(String id)
      Returns the HTML wrapped in an iframe to render in notebooks.
      Parameters:
      id - the iframe HTML id.