pub struct FieldDef {
pub aggregate: Option<AggregateOp>,
pub bin: Option<Bin>,
pub field: Option<Field>,
pub time_unit: Option<TimeUnit>,
pub title: Option<String>,
pub field_def_type: Type,
}
Expand description
Definition object for a data field, its type and transformation of an encoding channel.
A data field to use as a unique key for data binding. When a visualization’s data is updated, the key value will be used to match data elements to existing mark instances. Use a key channel to enable object constancy for transitions over dynamic data.
Latitude position of geographically projected marks.
Latitude-2 position for geographically projected ranged "area"
, "bar"
, "rect"
, and
"rule"
.
Longitude position of geographically projected marks.
Longitude-2 position for geographically projected ranged "area"
, "bar"
, "rect"
,
and "rule"
.
Fields§
§aggregate: Option<AggregateOp>
Aggregation function for the field
(e.g., mean
, sum
, median
, min
, max
, count
).
Default value: undefined
(None)
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
.
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.
field_def_type: Type
The encoded field’s type of measurement ("quantitative"
, "temporal"
, "ordinal"
, or
"nominal"
).
It can also be a "geojson"
type for encoding
‘geoshape’.