Skip to content

TickLabelSet

Overview

Shows a set of tick labels within or next to a chart.

@author Sam Reid (PhET Interactive Simulations)

Class TickLabelSet

import { TickLabelSet } from 'scenerystack/bamboo';

Constructor

new TickLabelSet( chartTransform : ChartTransform, axisOrientation : Orientation, spacing : number, providedOptions? : TickLabelSetOptions )

Instance Methods

setSpacing( spacing : number )

getSpacing() : number

update()

(protected)

Updates the labels when range or spacing has changed.

invalidateTickLabelSet()

Clears the cache and updates the label set. Use this if you need to have new labels for values that are in the cache. For example, if your createLabel function had logic to switch between numeric (e.g. 2) and symbolic labels (e.g. '2L').

setCreateLabel( createLabel : ( value: number ) => Node | null )

dispose()

getSpacingBorders() : Range

Type TickLabelSetOptions

import type { TickLabelSetOptions } from 'scenerystack/bamboo';
  • value?: number
  • edge?: null | "min" | "max"
  • origin?: number
  • skipCoordinates?: number[]
  • extent?: number
    act as if there is a corresponding tick with this extent, for positioning the label relatively
  • clippingType?: ClippingType
    determines whether the rounding is lenient, see ChartTransform
  • createLabel?: ( value: number ) => Node | null
    or return null if no label for that value
  • positionLabel?: ( label: Node, tickBounds: Bounds2, axisOrientation: Orientation ) => Node
  • & StrictOmit<PathOptions, "children">

Source Code

See the source for TickLabelSet.ts in the bamboo repository.