Skip to content
Rodrigo García-Herrera edited this page Feb 18, 2019 · 2 revisions

Scales are a crucial building block in visualization design: they transform a domain of data values into a range of visual values (pixels, colors, sizes, shapes, etc.).

When a data field is dropped over a mark property, Lyra tries to automatically infer a scale:

  1. If a related property already uses a scale, Lyra reuses it. For example, if a rect mark's X Start property uses a scale named A, dropping a field over the mark's Width property will reuse the A scale.
  2. Otherwise, Lyra looks to find an existing scale in the data pipeline with the dragged data field as its domain and a range that corresponds to the property type. For example, if field B was dropped over a mark's Fill Color property, Lyra will look to see if there's a color scale in the current pipeline whose domain is B.
  3. If it's not able to find an existing scale to reuse, Lyra creates a new scale automatically. The dragged field is set to the scale's domain, and the range uses a preset value dependent on the mark property the field was dropped over. This new scale will be listed under the Scales header of the pipeline.

Scales can also be created manually by clicking the + button under the data pipeline's Scales header, and any scales listed can be dragged and dropped to mark properties.

Type

A scale's type is dependent on the type of its domain. Ordinal scales have a discrete domain (such as names or categories), time scales have time domains, and the remaining types (called quantitative scales for example linear, log, etc.) have continuous domains (e.g. numbers).

A number of different options are available based on the scale type.

Ordinal Scales

  • Uniform: When checked, the scale distributes the range values at uniformly spaced points. This is most useful for point-based marks (symbol, line, area, text). The spacing of the points can be adjusted using the padding property. When unchecked, the scale instead constructs evenly-spaced bands, rather than points. This is most useful for setting the width or height of rect marks.

  • Padding: Applies spacing among the uniform points/bands of the scale's range.

Quantitative Scales

Quantitative scales include linear, log, pow, sqrt, quantile, and quantize and have these additional properties:

  • Clamp: if checked, data values that lie outside the specified domain are clamped to either the minimum or maximum range value.

  • Nice: if checked, Lyra rounds values in the domain to use more human-friendly number range (e.g. 7 instead of 6.96).

  • Zero: if checked, ensures that a zero baseline value is included in the scale domain.

Time Scales

Time scales include time and utc and have these additional properties:

  • Clamp: if checked, data values that lie outside the specified domain are clamped to either the minimum or maximum range value.

  • Nice: If a value is chosen from the dropdown, Lyra rounds values in the data domain to the particular time interval for a more human-friendly range value.

Domain

A scale's domain may either be drawn automatically from a data field (simply drag a field from the table, and drop it over the Field property), or may be specified manually. Set the From property to values and then enter domain values into the texboxes. For ordinal scales, enumerate all the necessary values of the domain. For quantitative scales, it's sufficient to just enter the minimum and maximum values. Lyra will automatically evaluate continuous values between these two.

Range

A scale's range can be either set manually (set From to values) or set to a built-in preset range. These built-in ranges are available for spatial, colors, shapes ranges. Simply select the appropriate range type, and drag the built-in range type.