Package smile.plot.vega
Class Field
java.lang.Object
smile.plot.vega.Field
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 TypeMethodDescriptionSets the aggregation function for the field (e.g., "mean", "sum", "median", "min", "max", "count").axis()
Returns the axis definition object.bin
(boolean flag) Turns on/off binning a quantitative field.Indicates that the data for x or y channel are binned before they are imported into Vega-Lite.Sets custom binning parameters.domain
(double... values) Sets the customize domain 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.legend()
Returns the legend definition object.range
(double... values) Sets the customize range 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.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.Sets the sorting property.spacing
(double spacing) For facet, row and column channels, sets the spacing in pixels between facet's sub-views.Sets the type of stacking offset if the field should be stacked.Sets the time unit for a temporal field.Sets the title for the field.Returns the specification in pretty print.toString()
Sets the field's type of measurement.zero
(boolean flag) If true, ensures that a zero baseline value is included in the scale domain.
-
Method Details
-
toString
-
toPrettyString
Returns the specification in pretty print.- Returns:
- the specification in pretty print.
-
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
Turns on/off binning a quantitative field.- Parameters:
flag
- If true, default binning parameters will be applied.- Returns:
- this object.
-
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
Sets custom binning parameters.- Parameters:
params
- the binning parameters.- Returns:
- this object.
-
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
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
Sets the title for the field. If null, the title will be removed.- Parameters:
title
- the title text.- Returns:
- this object.
-
scale
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
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
Sets the customize domain values.- Parameters:
values
- the domain values.- Returns:
- this object.
-
domain
Sets the customize domain values.- Parameters:
values
- the domain values.- Returns:
- this object.
-
domainMin
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
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
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
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
Sets the customize range values.- Parameters:
values
- the range values.- Returns:
- this object.
-
range
Sets the customize range values.- Parameters:
values
- the range values.- Returns:
- this object.
-
rangeMin
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
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
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
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
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
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
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
Returns the axis definition object.- Returns:
- the axis definition object.
-
legend
Returns the legend definition object.- Returns:
- the legend definition object.
-
removeLegend
Removes the legend for the encoding channel will be removed.
-