Skip to content

ISeriesPrimitiveAxisView requires fixedCoordinate() to be specified #1986

@tpunt

Description

@tpunt

Lightweight Charts™ Version: 5.0.9

Steps/code to reproduce:

When adding axis views for price, the fixedCoordinate() method is marked as optional in ISeriesPrimitiveAxisView. However, if this is not specified, then the recalculateOverlapping() function logic is broken. This is because it thinks it finds overlap when this is not true (example below). Even just above the calling location of this function, I'm not sure this logic works with plugins because we cannot set the fixed coordinate of plugin axis views in this way.

See the following plugin branch to demonstrate: https://github.com/tpunt/lwc-plugin-countdown-to-close/tree/no-fixed-coordinate

Screenshot:

Image

The axis label from createPriceLine() at price 700 is always moved to the top of the price axis.

Using this example, the top variable (used in the first call to recalculateOverlapping()) has the following two views:

[
    "view: label = '680.00, coord = 217.21754385964914, fixed coordinate = 0, height = 17",
    "view: label = '700.00, coord = 150.76140350877193, fixed coordinate = 150.76140350877193, height = 17"
]

After the call to recalculateOverlapping(), it has the following:

[
    "view: label = '680.00, cood = 217.21754385964914, fixed coordinate = 0, height = 17",
    "view: label = '700.00, cood = 150.76140350877193, fixed coordinate = 7.5, height = 17"
]

This is because recalculateOverlapping() finds overlap between the two labels, even though this is not true. The logic to check for overlap in this case is coordinate > prevFixedCoordinate - height, which is 150.76140350877193 > 0 - 17.

I'm not entirely sure what the fix should be here for this. It has taken quite some time to debug things this far. Any suggestions? Otherwise, I can have more of a think about how to resolve things this week.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugUnexpected problem or unintended behavior.

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions