Skip to content

Pattern Config

Configure built-in patterns to be applied to series fills.

patterns is a list section: it takes an array of config objects (a single object is also accepted and treated as a one-entry array). Values shared by every entry can be set once in patternDefaults; a value set on an individual entry wins over the shared one.

Every property is optional and falls back to its default, except type, which must be given. Property anchors are stable: link to any entry as #patterns.propertyName, and to a member of a nested property as #patterns.propertyName.memberName.

backgroundColor

The color behind the pattern marks: use "series" for the owning series color, "currentColor" to follow the host page CSS color, or null for a transparent background.

  • Default: null
  • Validation: should be a valid svg color (or "none" / "currentColor") or be equal to "series" or be equal to null
  • Used in: Patterns

backgroundOpacity

The opacity (0 - 1) of the pattern background when backgroundColor is not null.

  • Default: 1
  • Validation: should be a number >= to 0 and <= 1
  • Used in: Patterns

foregroundColor

The color of the pattern marks: use "series" for the owning series color or "currentColor" to follow the host page CSS color.

  • Default: "series"
  • Validation: should be a valid svg color (or "none" / "currentColor") or be equal to "series"
  • Used in: Patterns

foregroundOpacity

The opacity (0 - 1) of the pattern marks.

  • Default: 1
  • Validation: should be a number >= to 0 and <= 1
  • Used in: Patterns

id

The unique identifier for the pattern so that it can be referenced for use.

  • Default: P${index}
  • Validation: should be a string of letters, digits, dashes and underscores; should be unique
  • Used in: Patterns

ignore

Whether to ignore this pattern and treat it as though it were not specified.

  • Default: false
  • Validation: should be a boolean

lineWidth

The width (in pixels) of the strokes in a lines or crosshatch pattern.

  • Default: 2 — when type is lines or crosshatch
  • Validation: should be a number >= to 0 when type is lines or crosshatch; should be equal to undefined when type is dots
  • Used in: Patterns

radius

The radius (in pixels) of each dot in a dots pattern.

  • Default: 2 — when type is dots
  • Validation: should be a number >= to 0 when type is dots; should be equal to undefined when type is lines or crosshatch
  • Used in: Patterns

rotation

The clockwise rotation (in degrees, -360 to 360) of a lines or crosshatch pattern.

  • Default: 45 — when type is lines or crosshatch
  • Validation: should be a number >= to -360 and <= 360 when type is lines or crosshatch; should be equal to undefined when type is dots
  • Used in: Patterns

spacing

The screen-space distance (in pixels) between repeated pattern marks.

  • Default: 8
  • Validation: should be a number >= to 1
  • Used in: Patterns

type

The built-in pattern type (lines, crosshatch, or dots).

  • Required: a value must be given (there is no default)
  • Validation: should be one of [ "lines", "crosshatch", "dots" ]
  • Used in: Patterns

Released under the MIT License.