Create and Manage Encodings
Manage encodings to control how data maps to marks, channels, and layout behavior.
msc.encode(elem, channel, attribute, params)
Encodes a data attribute using a visual channel on an element.
elem: Mark or Groupchannel(String, required): visual channelattribute(String, required): data attributeparams(Object): has the following propertiesaggregator(String, optional): aggregator, defaults to"sum"scale(Scale, optional): the scale to use for the encodingscaleType(String, optional): type of scaleshareScale(Encoding, optional): share the scale of another encodingflipScale(Boolean, optional): whether the scale is flipped, defaults tofalseincludeZero(Boolean, optional): whether the scale domain includes 0, defaults tofalserangeExtent(Number, optional): range extentmapping(Object, optional): user-defined mapping between field values and visual propertiesscheme(String, optional): color schemestartAngle(Number, optional): start angle in degrees when encoding with the"angle"channel, defaults to90angleDirection(String, optional): direction to encode angles, defaults to"clockwise"
- Return type: Encoding
msc.getChannelEncodingByAttribute(attribute, channel, scene)
Returns the encoding for given attribute and channel within a scene.
attribute(String): data attributechannel(String): visual channelscene(Scene): the scene to search- Return type: Encoding or
null
msc.getChannelEncodingByElement(elem, channel)
Returns the encoding for the given channel on a specific element.
elem: Mark or Groupchannel(String): visual channel- Return type: Encoding or
null
msc.getEncodingsByChannel(channel, scene)
Returns all the encodings in the scene that use the given channel.
channel(String): visual channelscene(Scene): the scene to search- Return type: Array of Encodings
msc.getEncodingsByElement(elem, includeVertexSegment)
Returns all encodings associated with the element.
elem: Mark or GroupincludeVertexSegment(Boolean, optional): whether to also include encodings on the element’s vertices and segments- Return type: Array of Encodings
msc.removeEncoding(enc, scene)
Removes an encoding from the scene.