Skip to content

[Bug] weak_magnet mode doesn't snap correctly #782

@YoavShkedy

Description

@YoavShkedy

Version

10.0.0-beta1

Steps to Reproduce

  1. Create an overlay with mode: 'weak_magnet'
  2. Draw near a candle but slightly above the high
  3. Observe that it doesn't snap to the high value

Current Behavior

Point doesn't snap

Expected Behavior

Point should snap to the nearest OHLC value when within modeSensitivity pixels

Environment

- OS:
- Browser:
- Framework:

Any additional comments?

   In the source code around line 8748-8762, the weak_magnet logic 
   subtracts modeSensitivity instead of adding it when checking 
   if the cursor is close enough to snap:
   
   // When value > high:
   var buffValue = yAxis.convertFromPixel(highY - modeSensitivity);
   // This makes buffValue HIGHER than high, so the condition 
   // "value < buffValue" is rarely true
   
   // Should probably be:
   var buffValue = yAxis.convertFromPixel(highY + modeSensitivity);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions