WebCola
Options
All
  • Public
  • Public/Protected
  • All
Menu

A symbol generator.

Symbols provide a categorical shape encoding as is commonly used in scatterplots. Symbols are always centered at ⟨0,0⟩; use a transform (see: SVG, Canvas) to move the arc to a different position.

The first generic corresponds to the "this" context within which the symbol generator is invoked. The second generic corrsponds to the data type of the datum underlying the symbol.

Type parameters

  • This

  • Datum

Hierarchy

  • Symbol

Callable

  • __call(this: This, d?: Datum, ...args: any[]): string | null
  • __call(this: This, d?: Datum, ...args: any[]): void
  • Generates a symbol for the given arguments.

    IMPORTANT: If the rendering context of the symbol generator is null, then the symbol is returned as a path data string.

    The "this" context within which this function is invoked, will be the context within which the accessor methods of the generator are invoked. All arguments passed into this function, will be passed to the accessor functions of the generator.

    For example, with the default settings, no arguments are needed to produce a circle with area 64 square pixels.

    Parameters

    • this: This
    • Optional d: Datum

      The datum for which the symbol is to be generated.

    • Rest ...args: any[]

    Returns string | null

  • Generates an symbol for the given arguments.

    IMPORTANT: If the symbol generator has been configured with a rendering context, then the symbol is rendered to this context as a sequence of path method calls and this function returns void.

    The "this" context within which this function is invoked, will be the context within which the accessor methods of the generator are invoked. All arguments passed into this function, will be passed to the accessor functions of the generator.

    For example, with the default settings, no arguments are needed to produce a circle with area 64 square pixels.

    Parameters

    • this: This
    • Optional d: Datum

      The datum for which the symbol is to be generated.

    • Rest ...args: any[]

    Returns void

Index

Methods

Methods

context

  • context(): CanvasRenderingContext2D | null
  • context(context: CanvasRenderingContext2D)
  • context(context: null)
  • Returns the current rendering context, which defaults to null.

    Returns CanvasRenderingContext2D | null

  • Sets the rendering context and returns this symbol generator.

    If the context is not null, then the generated symbol is rendered to this context as a sequence of path method calls.

    Parameters

    • context: CanvasRenderingContext2D

      The rendering context.

  • Sets the rendering context to null and returns this symbol generator.

    A path data string representing the generated symbol will be returned when the generator is invoked with data.

    Parameters

    • context: null

      null, to remove rendering context.

size

  • size(): function
  • size(size: number)
  • size(size: function)
  • Returns the current size accessor, which defaults to a function returning a constant value of 64.

    Returns function

      • (this: This, d: Datum, ...args: any[]): number
      • Parameters

        • this: This
        • d: Datum
        • Rest ...args: any[]

        Returns number

  • Sets the size to the specified number and returns this symbol generator.

    Parameters

    • size: number

      A fixed size (area in square pixels).

  • Sets the size to the specified function and returns this symbol generator.

    Specifying the size as a function is useful for constructing a scatterplot with a size encoding. If you wish to scale the symbol to fit a given bounding box, rather than by area, try SVG’s getBBox.

    Parameters

    • size: function

      An accessor function returning a number to be used as a symbol size. The accessor function is invoked in the same "this" context as the generator was invoked in and receives the same arguments that were passed into the symbol generator.

        • (this: This, d: Datum, ...args: any[]): number
        • Parameters

          • this: This
          • d: Datum
          • Rest ...args: any[]

          Returns number

type

  • type(): function
  • type(type: SymbolType)
  • type(type: function)
  • Returns the current symbol type accessor, which defaults to a function returning the circle symbol type.

    Returns function

      • (this: This, d: Datum, ...args: any[]): SymbolType
      • Parameters

        • this: This
        • d: Datum
        • Rest ...args: any[]

        Returns SymbolType

  • Sets the symbol type to the specified symbol type and returns this symbol generator.

    Parameters

  • Sets the symbol type to the specified function and returns this symbol generator.

    Parameters

    • type: function

      An accessor function returning a symbol type. The accessor function is invoked in the same "this" context as the generator was invoked in and receives the same arguments that were passed into the symbol generator. See symbols for the set of built-in symbol types. To implement a custom symbol type, return an object that implements symbolType.draw.

        • (this: This, d: Datum, ...args: any[]): SymbolType
        • Parameters

          • this: This
          • d: Datum
          • Rest ...args: any[]

          Returns SymbolType

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc