Encoding

The encoding property contains a list of one or more channel-to-data encoding which describes how a data field or attribute is mapped to a visual channel / property of the visual mark. Specifying this encoding is essentially the main job of a visualization designer. As described in the Mark documentation page, DXR provides a set of generic visual channels that can be mapped to data. These generic or default channels are documented below (under Possible Values column for channel specification). You can also see the actual implementation for modifying these channels / properties in the generic mark script.

Note that the channel properties are applied to the mark game object in the order they are provided in the encoding list - in some cases, e.g., when rotation and translation are involved, this ordering might affect the resulting visualization. Also note that the pivot point (point on which the object rotates around, or gets resized around) position of a mark affects how the position, size, and orientation channels behave - in most cases, the pivot point of a mark game object is in its center (e.g., as in the cube and sphere marks).

As described in the initial Grammar Docs page, DXR applies automatic inferrence to the designer's provided vis specs, i.e., given a concise vis specs, DXR expands it to a complete vis specs with all necessary properties to create the visualization, using the most sensible default settings. In order to enable this inferrence, the designer needs to provide a minimum set of required properties of a channel encoding: channel, field or value, and type. Given these, DXR can infer the rest of the specification properties. The channel property specifies which channel will be used, while the field property specifies which data attribute will be used in the encoding. Note that both channel and field properties are case sensitive, i.e., generic channels are all lowercase; custom channels follow the case described in their custom mark script (see SetChannelValue function implementation); field property should match case in data values. When a value property is specified, the channel is set to this constant value without using a scaling function. The type property specifies the type of the data field or attribute - we follow Vega-Lite's type specifications - please refer to Vega-Lite's type documentation for more detail, though DXR currently only supports: quantitative, ordinal, and nominal data types.

The scale, axis, and legend specifications are documented in detail separately.

Below is an example of a simple visualization that uses the generic mark cube with generic visual channels: x, y, color, and opacity.

To get a better sense of what the different generic visual channels mean, take a look at the several examples provided in the Examples page. The available marks and channels in the grammar can be extended by creating custom marks and channels, allowing for more engaging and innovative visualizations.