Class that represents a single Axis tick that can be managed by the user.

Custom ticks are created with addCustomTick.

Frequently used methods:

Method Purpose
setValue Set tick position along Axis.
setTextFormatter Set tick label text using a callback function.
dispose Destroy tick permanently
setGridStrokeStyle Set tick gridline style
setTickLength Set tick line length as pixels
setTickLabelPadding Set padding between tick line and label

Styling CustomTicks:

Tick gridline can be styled with setGridStrokeStyle

TickMarker (label, tick, possible background) are styled via setMarker as a callback function, like this:

 CustomTick.setMarker((tickMarker) => tickMarker
// Style TickMarker.
.setTextFillStyle(new SolidFill({ color: ColorRGBA( 255, 0, 0 ) }))
.setFont((font) => font.setStyle( 'italic' ))
)

See TickMarker for available customization API.

Styling specific TickMarkers:

When a custom tick is created, a tick marker builder can be specified. This specifies the shape, and general visual look of the custom tick, and can also expose a larger set of customization API for the tick marker. To use the specific API, it is required to cast the tick marker object to the correct type (TypeScript users only):

 const customTick = Axis.addCustomTick(UIElementBuilders.PointableTextBox)
customTick.setMarker((tickMarker: UIPointableTextBox) => tickMarker
// ^ Above type cast is necessary to access full configuration API of UIPointableTextBox
// Style TickMarker background fill color.
.setBackground((background) => background
.setFillStyle(new SolidFill({ color: ColorRGBA(255, 0, 0, 100) }))
)
)

For reference,

  • CustomTick created with UIElementBuilders.AxisTickMajor or UIElementBuilders.AxisTickMinor will support API as described by UITick
  • CustomTick created with UIElementBuilders.PointableTextBox will support API as described by UIPointableTextBox

Hierarchy

Implements

Properties

axis: Axis

Axis that CustomTick belongs to.

axisScale: LinearScale1D | LogarithmicScale1D
renderingScale: LinearScaleXY

Accessors

  • get draggable(): boolean
  • Returns boolean

  • set draggable(state: boolean): void
  • Parameters

    • state: boolean

    Returns void

Methods

  • Add callback function to be triggered when specified event is fired.

     // Example syntax
    object.addEventListener('click', (event) => {
    console.log(event)
    })

    Some classes also report extra information about the interacted object with the second parameter:

     // Most series share information about interacted data point
    series.addEventListener('click', (event, info) => {
    console.log(info)
    })

    Optional third parameter allows registering event handlers that will automatically remove themselves after first trigger:

     // Example this listener will only fire once
    object.addEventListener('click', (event) => {})

    Each class has its own list of supported events. Some events are from HTML standard (click, pointerdown, etc.), while others are own events from LightningChart JS (dispose, resize, etc.)

    To find what events are available, you can try following:

    • If your development environment has TypeScript enabled, just write addEventListener and see what possible event types the IDE suggests. These APIs are strongly typed, and even the callback event will be correctly typed.
    • Otherwise, open the class section in API documentation and check out which interface K type parameter extends.

    Type Parameters

    Parameters

    Returns void

  • Permanently destroy the component.

    To fully allow Garbage-Collection to free the resources used by the component, make sure to remove any references to the component and its children in application code.

    let chart = ...ChartXY()
    let axisX = chart.getDefaultAxisX()
    // Dispose Chart, and remove all references so that they can be garbage-collected.
    chart.dispose()
    chart = undefined
    axisX = undefined

    Returns

    Object itself for fluent interface

    Returns CustomTick

  • Get whether CustomTick should allocate space on its Axis.

    By default, this is true, which means that Axis will always make sure it is big enough to fit the tick.

    By setting to false, this particular CustomTick can be removed from this behaviour, which can be useful in applications where some custom ticks are only enabled temporarily. Disabling this functionality can prevent the size of the Axis from changing in unwanted ways.

    Returns

    Boolean flag.

    Returns boolean

  • Returns

    Grid stroke length as a % of the viewport size

    Returns number

  • Returns

    Grid stroke style as a LineStyle object

    Returns LineStyle

  • Get custom ticks TickMarker (label, tick, possible background).

    Returns

    TickMarker object

    Returns TickMarker

  • Get marker visible or not.

    Returns

    Boolean.

    Returns boolean

  • Get pixel padding between tick line and label.

    Returns number

  • Get rotation of tick label.

    Returns

    Rotation in degrees

    Returns number

  • Get tick length as pixels.

    Returns

    Tick length as pixels.

    Returns number

  • Value of CustomTick

    Returns number

  • Get element visibility.

    Returns

    true when element is set to be visible and false otherwise.

    Returns boolean

  • Check that customTick fit the main scale

    Returns

    Boolean with the result

    Returns boolean

  • Remove event listener added using addEventListener. The expected argument should be the exact same callback function that was supplied using addEventListener:

     // Basic example syntax
    const listener = () => {}
    obj.addEventListener('click', listener)
    obj.removeEventListener('click', listener)
     // Basic boilerplate of custom interaction when user drags on an object
    obj.addEventListener('pointerdown', (eventDown) => {
    let prevCoord = eventDown
    const handlePointerMove: LCJSInteractionEventListener<'pointermove'> = (eventMove) => {
    const delta = { x: eventMove.clientX - prevCoord.clientX, y: eventMove.clientY - prevCoord.clientY }
    prevCoord = eventMove
    console.log(delta, eventMove.clientX, eventMove.clientY)
    }
    const handlePointerUp: LCJSInteractionEventListener<'pointerup'> = (eventUp) => {
    window.removeEventListener('pointermove', handlePointerMove)
    window.removeEventListener('pointerup', handlePointerUp)
    }
    window.addEventListener('pointermove', handlePointerMove)
    window.addEventListener('pointerup', handlePointerUp)
    })

    Type Parameters

    Parameters

    Returns void

  • Set whether CustomTick should allocate space on its Axis.

    By default, this is true, which means that Axis will always make sure it is big enough to fit the tick.

    By setting to false, this particular CustomTick can be removed from this behaviour, which can be useful in applications where some custom ticks are only enabled temporarily. Disabling this functionality can prevent the size of the Axis from changing in unwanted ways.

     // Example syntax, disable custom tick space allocation.
    CustomTick.setAllocatesAxisSpace(false)

    Returns

    Object itself for fluent interface.

    Parameters

    • shouldAxisAllocateSpace: boolean

      Boolean flag.

    Returns CustomTick

  • Set length of grid stroke in percents

    Returns

    This for fluent interface

    Parameters

    • length: number

      Grid line length as a % of viewport size

    Returns CustomTick

  • Configure custom ticks TickMarker (label, tick, possible background) via a callback function.

    Example usage:

     CustomTick.setMarker((tickMarker) => tickMarker
    // Style TickMarker.
    .setTextFillStyle(new SolidFill({ color: ColorRGBA( 255, 0, 0 ) }))
    .setFont((font) => font.setStyle( 'italic' ))
    )

    See TickMarker for available customization API.

    Styling specific TickMarkers:

    When a custom tick is created, a tick marker builder can be specified. This specifies the shape, and general visual look of the custom tick, and can also expose a larger set of customization API for the tick marker. To use the specific API, it is required to cast the tick marker object to the correct type (TypeScript users only):

     const customTick = Axis.addCustomTick(UIElementBuilders.PointableTextBox)
    customTick.setMarker((tickMarker: UIPointableTextBox) => tickMarker
    // ^ Above type cast is necessary to access full configuration API of UIPointableTextBox
    // Style TickMarker background fill color.
    .setBackground((background) => background
    .setFillStyle(new SolidFill({ color: ColorRGBA(255, 0, 0, 100) }))
    )
    )

    For reference,

    • CustomTick created with UIElementBuilders.AxisTickMajor will support API as described by UITick
    • CustomTick created with UIElementBuilders.PointableTextBox will support API as described by UIPointableTextBox

    Parameters

    Returns CustomTick

  • Set marker visible or not.

    Returns

    Object itself

    Parameters

    • visible: boolean

      Marker visible?

    Returns CustomTick

  • Set mouse interactions enabled or disabled

    Returns

    Object itself for fluent interface

    Parameters

    • state: boolean

      Specifies state of mouse interactions

    Returns CustomTick

  • Set text of CustomTicks' Marker with a formatting function.

    Example usage:

    // Marker shows formatted position of CustomTick on its Axis
    CustomTick.setTextFormatter((position, customTick) => customTick.axis.formatValue(position))
    // Marker shows 'Hello world'
    CustomTick.setTextFormatter((position, customTick) => 'Hello world')

    Returns

    Object itself

    Parameters

    • textFormatter: CustomTickTextFormatter

      A function of type: CustomTickTextFormatter, that defines text of CustomTicks' Marker.

    Returns CustomTick

  • Set pixel padding between tick line and label.

    Parameters

    • padding: number

    Returns CustomTick

  • Set rotation of tick label.

    Returns

    Object itself

    Parameters

    • value: number

      Rotation in degrees

    Returns CustomTick

  • Set tick length as pixels.

    Returns

    Object itself for fluent interface.

    Parameters

    • length: number

      Tick length as pixels.

    Returns CustomTick

  • Sets the position of this custom tick on its Axis

    Returns

    This for fluid interface

    Remarks

    Overrides text of CustomTicks Marker with formated value.

    Parameters

    • value: number

      Value in the units of main scale

    Returns CustomTick

  • Set element visibility.

    Returns

    Object itself.

    Parameters

    • state: boolean

      true when element should be visible and false when element should be hidden.

    Returns CustomTick