Interface for end user API of the LCJS engine. It provides some useful capabilities over the area enclosed by a single LCJS context (which can be just a single chart, or a Dashboard with several charts).

Commonly used properties:

  • layout: Trigger resizing of charts.
  • captureFrame: Take a screenshot of charts.
  • scale: Coordinate system that encloses entire LCJS context in pixels starting from bottom left.
  • clientLocation2Engine: Translate web page coordinate to LCJS engine coordinate.
  • engineLocation2Client: Translate LCJS engine coordinate to web page coordinate.

Hierarchy

  • PublicEngine

Properties

container: HTMLDivElement

HTML Div element that contains the rendering Engine.

restoreMouseStyle: ((key?: number) => void)

Type declaration

    • (key?: number): void
    • Restore Mouse style.

      Parameters

      • Optional key: number

        Key generated using 'setMouseStyle'

      Returns void

setMouseStyle: ((presetName: string, existingKey?: number) => number)

Type declaration

    • (presetName: string, existingKey?: number): number
    • Set Mouse style.

      Returns

      Key that can be used to restore Mouse style

      Parameters

      • presetName: string

        Name of a Mouse preset in js.

      • Optional existingKey: number

        Key for existing request to refresh

      Returns number

Methods

  • Register a custom Icon that can be used within the engine (all charts, panels, series, etc. using the same engine).

    Note that currently the Icon concept is not widely supported, and can only be used with the DataGrid feature as cell content. In the future, Icons will be more widely utilizable, for example in Legends, Cursors and UI elements.

     // Example, load a custom icon.
    const img = new Image()
    img.src = `my-icon-url.jpg`
    const icon = chart.engine.addCustomIcon(img, {})

    Icon properties can be supplied with the optional second parameter. For all available options, see IconProperties.

     // Example, specify icon width as pixels and maintain source aspect ratio.
    const icon = chart.engine.addCustomIcon(img, { width: 32 })

    Icon properties can also be adjusted using setter methods on an existing Icon object. All setters return a new Icon object, leaving the original Icon unmodified!

     // Example, make a second Icon object by adjusting an existing one.
    const icon2 = icon.setSize(16, 24)

    When a custom icon is no longer needed, it is recommended to inform the engine by disposing the Icon:

     // Example, inform engine that an Icon is no longer needed.
    icon.dispose()

    Returns

    Icon object.

    Parameters

    Returns Icon

  • Capture state of rendering Engines canvas. Returns the captured image as a Blob-object.

    Has two optional parameters which directly reference JavaScript API HTMLCanvasElement.toDataURL:

    https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL

    Returns

    JavaScript Blob whose 'type' depends on what was passed to 'type' parameter of this method. Or as a data url if the asDataUrl option was set to true Defaults to image/png

    Parameters

    • Optional type: string

      A DOMString indicating the image format. The default format type is image/png.

    • Optional encoderOptions: number

      A Number between 0 and 1 indicating the image quality to use for image formats that use lossy compression such as image/jpeg and image/webp. If this argument is anything else, the default value for image quality is used. The default value is 0.92. Other arguments are ignored.

    Returns Blob

  • Parameters

    • Optional type: string
    • Optional encoderOptions: number
    • Optional asDataUrl: boolean

    Returns string | Blob

  • Get Fill Style of engine background.

    Returns

    FillStyle

    Returns FillStyle

  • Get Stroke Style of engine background.

    Returns

    LineStyle

    Returns LineStyle

  • Calculate the layout again.

    This is used to inform charts that their position may have changed as a result of an Event that the charts are not aware of. For example, if the chart is positioned within a scrollable DIV.

     // Example syntax, trigger chart layout when it is scrolled.
    div.onscroll = () => chart.engine.layout()

    Returns void

  • Remove callback from event when engine renders a frame.

    Returns

    Boolean whether subscription was removed or not

    Parameters

    • token: Token

      Token that was received when subscribing to the event.

    Returns boolean

  • Add callback function which is triggered whenever the engine renders a frame.

    Can be used for FPS measurement and debugging mainly.

    Returns

    Token which can be used to unsubscribe from event.

    Parameters

    • clbk: (() => void)

      Function which is called on event.

        • (): void
        • Returns void

    Returns Token

  • Render a frame of specific size to a ArrayBuffer.

    Mainly for Node JS usage. In browser the chart itself will not be resized correctly.

    Parameters

    • width: number

      Horizontal resolution

    • height: number

      Vertical resolution

    • Optional noFlip: boolean

      Leave the image upside down

    Returns Uint8Array

  • Set Fill Style of engine background.

    Every LCJS component has an Engine background under it. In case of Dashboard, there is only 1 shared engine background.

    Transparent chart backgrounds:

    LightningChart JS charts can be configured to be fully or partially transparent.

     // Example, partially transparent chart

    // Engine background exists under all LCJS components. In case of Dashboard, there is only 1 shared engine background.
    chart.engine.setBackgroundFillStyle(emptyFill)
    // Chart background covers every 1 chart. In case of Dashboard, every chart has its own chart background.
    chart.setBackgroundFillStyle(new SolidFill({ color: ColorRGBA(0, 0, 0, 100) }))
    // Some charts also have a separate series background.
    chart.setSeriesBackgroundFillStyle(new SolidFill({ color: ColorRGBA(0, 0, 0, 100) }))

    Returns

    Object itself

    Parameters

    Returns PublicEngine