pub struct XClass {
pub aggregate: Option<AggregateOp>,
pub axis: Option<Axis>,
pub bin: Option<Bin>,
pub field: Option<Field>,
pub scale: Option<Scale>,
pub sort: Option<Sort>,
pub stack: Option<StackOffset>,
pub time_unit: Option<TimeUnit>,
pub title: Option<String>,
pub def_type: Option<Type>,
pub value: Option<PurpleValue>,
}
Expand description
X coordinates of the marks, or width of horizontal "bar"
and "area"
.
Y coordinates of the marks, or height of vertical "bar"
and "area"
.
Definition object for a constant value of an encoding channel.
Fields§
§aggregate: Option<AggregateOp>
Aggregation function for the field
(e.g., mean
, sum
, median
, min
, max
, count
).
Default value: undefined
(None)
axis: Option<Axis>
An object defining properties of axis’s gridlines, ticks and labels.
If null
, the axis for the encoding channel will be removed.
Default value: If undefined, default axis properties are applied.
bin: Option<Bin>
A flag for binning a quantitative
field, or an object defining binning
parameters.
If true
, default binning parameters
will be applied.
Default value: false
field: Option<Field>
Required. A string defining the name of the field from which to pull a data value
or an object defining iterated values from the
repeat
operator.
Note: 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\\]"
).
See more details about escaping in the field
documentation.
Note: field
is not required if aggregate
is count
.
scale: Option<Scale>
An object defining properties of the channel’s scale, which is the function that transforms values in the data domain (numbers, dates, strings, etc) to visual values (pixels, colors, sizes) of the encoding channels.
If null
, the scale will be disabled and the data value will be directly
encoded.
Default value: If undefined, default scale properties are applied.
sort: Option<Sort>
Sort order for the encoded field.
For continuous fields (quantitative or temporal), sort
can be either "ascending"
or
"descending"
.
For discrete fields, sort
can be one of the following:
"ascending"
or"descending"
– for sorting by the values’ natural order in Javascript.- A sort field definition for sorting by another field.
- An array specifying the field values in preferred
order. In this case, the
sort order will obey the values in the array, followed by any unspecified values in their
original order. For discrete time field, values in the sort array can be date-time
definition objects. In addition, for time units
"month"
and"day"
, the values can be the month or day names (case insensitive) or their 3-letter initials (e.g.,"Mon"
,"Tue"
). null
indicating no sort.
Default value: "ascending"
Note: null
is not supported for row
and column
.
stack: Option<StackOffset>
Type of stacking offset if the field should be stacked.
stack
is only applicable for x
and y
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.
-"center"
- stacking with center baseline (for streamgraph).null
- No-stacking. This will produce layered bar and area chart.
Default value: zero
for plots with all of the following conditions are true:
(1) the mark is bar
or area
;
(2) the stacked measure channel (x or y) has a linear scale;
(3) At least one of non-position channels mapped to an unaggregated field that is
different from x and y. Otherwise, null
by default.
time_unit: Option<TimeUnit>
Time unit (e.g., year
, yearmonth
, month
, hours
) for a temporal field.
or a temporal field that gets casted as
ordinal.
Default value: undefined
(None)
title: Option<String>
A title for the field. If null
, the title will be removed.
Default value: derived from the field’s name and transformation function
(aggregate
, bin
and timeUnit
). If the field has an aggregate function, the
function is displayed as part of the title (e.g., "Sum of Profit"
). If the field is
binned or has a time unit applied, the applied function is shown in parentheses (e.g.,
"Profit (binned)"
, "Transaction Date (year-month)"
). Otherwise, the title is simply
the field name.
Notes:
-
You can customize the default field title format by providing the [
fieldTitle
property in the config orfieldTitle
function via thecompile
function’s options. -
If both field definition’s
title
and axis, header, or legendtitle
are defined, axis/header/legend title will be used.
def_type: Option<Type>
The encoded field’s type of measurement ("quantitative"
, "temporal"
, "ordinal"
, or
"nominal"
).
It can also be a "geojson"
type for encoding
‘geoshape’.
value: Option<PurpleValue>
A constant value in visual domain (e.g., "red"
/ “#0099ff” for color, values between
0
to 1
for opacity).