• Function for translating a XY coordinate between different coordinate systems.

    A coordinate system can be selected by a scale property of chart, or by specifying a pair of Axis.

     // Example 1, translate from percentage location in chart, to pixel location in chart.
    const pixelLocation = translatePoint(
    // percentage location within chart, where [0,0] = bottom left, and [100,100] = top right.
    { x: 10, y: 10 },
    chart.uiScale,
    chart.pixelScale
    )
     // Example 2, translate axis coordinate to pixel location in chart.
    const pixelLocation = translatePoint(
    // axis coordinate.
    { x: 116.9, y: 26.4 },
    {
    x: chart.getDefaultAxisX(),
    y: chart.getDefaultAxisY(),
    },
    chart.pixelScale
    )

    // NOTE: Translation from chart pixel coordinates to *document* is done using `engineLocation2Client` method.
    const pixelLocationDocument = chart.engine.engineLocation2Client(pixelLocation.x, pixelLocation.y)
    // `pixelLocationDocument` can now be used for absolute positioning HTML elements, or other such things...

    Available chart coordinate systems:

    Every LCJS chart class has two available coordinate systems:

    1. uiScale | Percentage based coordinate system, where [0,0] = bottom left, and [100,100] = top right.
    2. pixelScale | Pixel based coordinate system, where [0,0] = bottom left.

    With ChartXY, axes can be also used (see example usage above).

    Returns

    Coordinate that corresponds value on target coordinate system.

    Deprecated

    Deprecated since v4.2.0. Deprecated over translateCoordinate and translateCoordinate

    Type Parameters

    Parameters

    • value: DataPoint

      XY coordinate.

    • originScale: ScaleXY<ViewportScale1D> | Vec2<ScaleXY<ViewportScale1D> | Axis>

      Source coordinate system.

    • targetScale: ScaleXY<ViewportScale1D> | Vec2<ScaleXY<ViewportScale1D> | Axis>

      Target coordinate system.

    Returns DataPoint