Class Field

java.lang.Object
smile.plot.vega.Field

public class Field extends Object
Encoding field definition object. An integral part of the data visualization process is encoding data with visual properties of graphical marks. The encoding property of a single view specification represents the mapping between encoding channels (such as x, y, or color) and data fields, constant visual values, or constant data values (datum).
  • Method Summary

    Modifier and Type
    Method
    Description
    aggregate(String aggregate)
    Sets the aggregation function for the field (e.g., "mean", "sum", "median", "min", "max", "count").
    Returns the axis definition object.
    bin(boolean flag)
    Turns on/off binning a quantitative field.
    bin(String bin)
    Indicates that the data for x or y channel are binned before they are imported into Vega-Lite.
    bin(BinParams params)
    Sets custom binning parameters.
    domain(double... values)
    Sets the customize domain values.
    domain(String... values)
    Sets the customize domain values.
    domainMax(double max)
    Sets the maximum value in the scale domain, overriding the domain property or the default domain.
    Sets the maximum value in the scale domain, overriding the domain property or the default domain.
    domainMin(double min)
    Sets the minimum value in the scale domain, overriding the domain property or the default domain.
    Sets the minimum value in the scale domain, overriding the domain property or the default domain.
    Returns the legend definition object.
    range(double... values)
    Sets the customize range values.
    range(String... values)
    Sets the customize range values.
    rangeMax(double max)
    Sets the maximum value in the scale range, overriding the range property or the default range.
    Sets the maximum value in the scale range, overriding the range property or the default range.
    rangeMin(double min)
    Sets the minimum value in the scale range, overriding the range property or the default range.
    Sets the minimum value in the scale range, overriding the range property or the default range.
    Removes the legend for the encoding channel will be removed.
    scale(String type)
    Sets the function that transforms values in the data domain (numbers, dates, strings, etc.) to visual values (pixels, colors, sizes) for position and mark property channels.
    sort(String value)
    Sets the sorting property.
    spacing(double spacing)
    For facet, row and column channels, sets the spacing in pixels between facet's sub-views.
    stack(String type)
    Sets the type of stacking offset if the field should be stacked.
    timeUnit(String timeUnit)
    Sets the time unit for a temporal field.
    title(String title)
    Sets the title for the field.
    Returns the specification in pretty print.
     
    type(String type)
    Sets the field's type of measurement.
    zero(boolean flag)
    If true, ensures that a zero baseline value is included in the scale domain.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • 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.
    • type

      public Field type(String type)
      Sets the field's type of measurement.
      Parameters:
      type - The encoded field's type of measurement ("quantitative", "temporal", "ordinal", or "nominal"). It can also be a "geojson" type for encoding ‘geoshape'.

      Data type describes the semantics of the data rather than the primitive data types (number, string, etc.). The same primitive data type can have different types of measurement. For example, numeric data can represent quantitative, ordinal, or nominal data.

      Data values for a temporal field can be either a date-time string (e.g., "2015-03-07 12:32:17", "17:01", "2015-03-16", "2015") or a timestamp number (e.g., 1552199579097).

      Returns:
      this object.
    • bin

      public Field bin(boolean flag)
      Turns on/off binning a quantitative field.
      Parameters:
      flag - If true, default binning parameters will be applied.
      Returns:
      this object.
    • bin

      public Field bin(String bin)
      Indicates that the data for x or y channel are binned before they are imported into Vega-Lite.
      Parameters:
      bin - it should be set to "binned".
      Returns:
      this object.
    • bin

      public Field bin(BinParams params)
      Sets custom binning parameters.
      Parameters:
      params - the binning parameters.
      Returns:
      this object.
    • timeUnit

      public Field timeUnit(String timeUnit)
      Sets the time unit for a temporal field. Vega-Lite supports the following time units:

      "year" - Gregorian calendar years. "quarter" - Three-month intervals, starting in one of January, April, July, and October. "month" - Calendar months (January, February, etc.). "date" - Calendar day of the month (January 1, January 2, etc.). "week" - Sunday-based weeks. Days before the first Sunday of the year are considered to be in week 0, the first Sunday of the year is the start of week 1, the second Sunday week 2, etc. "day" - Day of the week (Sunday, Monday, etc.). "dayofyear" - Day of the year (1, 2, …, 365, etc.). "hours" - Hours of the day (12:00am, 1:00am, etc.). "minutes" - Minutes in an hour (12:00, 12:01, etc.). "seconds" - Seconds in a minute (12:00:00, 12:00:01, etc.). "milliseconds" - Milliseconds in a second.

      Parameters:
      timeUnit - Time unit.
      Returns:
      this object.
    • aggregate

      public Field aggregate(String aggregate)
      Sets the aggregation function for the field (e.g., "mean", "sum", "median", "min", "max", "count").
      Parameters:
      aggregate - Aggregation function for the field.
      Returns:
      this object.
    • title

      public Field title(String title)
      Sets the title for the field. If null, the title will be removed.
      Parameters:
      title - the title text.
      Returns:
      this object.
    • scale

      public Field scale(String type)
      Sets the function that transforms values in the data domain (numbers, dates, strings, etc.) to visual values (pixels, colors, sizes) for position and mark property channels.

      Vega-Lite supports the following categories of scale types:

      1) Continuous Scales - mapping continuous domains to continuous output ranges ("linear", "pow", "sqrt", "symlog", "log", "time", "utc".

      2) Discrete Scales - mapping discrete domains to discrete ("ordinal") or continuous ("band" and "point") output ranges.

      3) Discretizing Scales - mapping continuous domains to discrete output ranges "bin-ordinal", "quantile", "quantize" and "threshold".

      Parameters:
      type - the function name. If null, the scale will be disabled and the data value will be directly encoded.
      Returns:
      this object.
    • zero

      public Field zero(boolean flag)
      If true, ensures that a zero baseline value is included in the scale domain.
      Parameters:
      flag - If true, ensures that a zero baseline value is included in the scale domain.
      Returns:
      this object.
    • domain

      public Field domain(double... values)
      Sets the customize domain values.
      Parameters:
      values - the domain values.
      Returns:
      this object.
    • domain

      public Field domain(String... values)
      Sets the customize domain values.
      Parameters:
      values - the domain values.
      Returns:
      this object.
    • domainMin

      public Field domainMin(double min)
      Sets the minimum value in the scale domain, overriding the domain property or the default domain. This property is only intended for use with scales having continuous domains.
      Parameters:
      min - the minimum value in the scale domain.
      Returns:
      this object.
    • domainMin

      public Field domainMin(String min)
      Sets the minimum value in the scale domain, overriding the domain property or the default domain. This property is only intended for use with scales having continuous domains.
      Parameters:
      min - the minimum value in the scale domain.
      Returns:
      this object.
    • domainMax

      public Field domainMax(double max)
      Sets the maximum value in the scale domain, overriding the domain property or the default domain. This property is only intended for use with scales having continuous domains.
      Parameters:
      max - the maximum value in the scale domain.
      Returns:
      this object.
    • domainMax

      public Field domainMax(String max)
      Sets the maximum value in the scale domain, overriding the domain property or the default domain. This property is only intended for use with scales having continuous domains.
      Parameters:
      max - the maximum value in the scale domain.
      Returns:
      this object.
    • range

      public Field range(double... values)
      Sets the customize range values.
      Parameters:
      values - the range values.
      Returns:
      this object.
    • range

      public Field range(String... values)
      Sets the customize range values.
      Parameters:
      values - the range values.
      Returns:
      this object.
    • rangeMin

      public Field rangeMin(double min)
      Sets the minimum value in the scale range, overriding the range property or the default range. This property is only intended for use with scales having continuous ranges.
      Parameters:
      min - the minimum value in the scale range.
      Returns:
      this object.
    • rangeMin

      public Field rangeMin(String min)
      Sets the minimum value in the scale range, overriding the range property or the default range. This property is only intended for use with scales having continuous ranges.
      Parameters:
      min - the minimum value in the scale range.
      Returns:
      this object.
    • rangeMax

      public Field rangeMax(double max)
      Sets the maximum value in the scale range, overriding the range property or the default range. This property is only intended for use with scales having continuous ranges.
      Parameters:
      max - the maximum value in the scale range.
      Returns:
      this object.
    • rangeMax

      public Field rangeMax(String max)
      Sets the maximum value in the scale range, overriding the range property or the default range. This property is only intended for use with scales having continuous ranges.
      Parameters:
      max - the maximum value in the scale range.
      Returns:
      this object.
    • sort

      public Field sort(String value)
      Sets the sorting property.
      Parameters:
      value - "ascending", "descending", or an encoding channel name to sort by (e.g., "-x" to sort by x-field, descending).
      Returns:
      this object.
    • stack

      public Field stack(String type)
      Sets the type of stacking offset if the field should be stacked. stack is only applicable for x, y, theta, and radius channels with continuous domains. For example, stack of y can be used to customize stacking for a vertical bar chart.

      Stack can be one of the following values:

      "zero" - stacking with baseline offset at zero value of the scale (for creating typical stacked bar and area chart).

      "normalize" - stacking with normalized domain (for creating normalized stacked bar and area charts and pie charts with percentage tooltip).

      "center" - stacking with center baseline (for streamgraph).

      null - No-stacking. This will produce layered bar and area chart.

      Parameters:
      type - "zero", "normalize", "center", or null.
    • spacing

      public Field spacing(double spacing)
      For facet, row and column channels, sets the spacing in pixels between facet's sub-views.
      Parameters:
      spacing - the spacing in pixels between facet's sub-views.
      Returns:
      this object.
    • axis

      public Axis axis()
      Returns the axis definition object.
      Returns:
      the axis definition object.
    • legend

      public Legend legend()
      Returns the legend definition object.
      Returns:
      the legend definition object.
    • removeLegend

      public Field removeLegend()
      Removes the legend for the encoding channel will be removed.