lightweight-charts icon indicating copy to clipboard operation
lightweight-charts copied to clipboard

Calling `chart.subscribeCrosshairMove()` throws "Value is undefined" when hovering mouse over the chart

Open francisashley opened this issue 1 year ago • 3 comments

Lightweight Charts™ Version: 4.1.2

Steps/code to reproduce:

  1. Provide valid data
  2. Add a call to chart.subscribeCrosshairMove()
  3. Hover the mouse over the timeline
  4. Alternates between throwing errors and triggering the callback just fine.

See the stackblitz example and screen recording below. Actual behavior:

When calling chart.subscribeCrosshairMove(), an error "Value is undefined" is thrown when hovering mouse over the chart.

Expected behavior:

An error should not be thrown.. ? The callback is still firing fine most of the time. However the error also keeps randomly throwing.

Screenshots:

https://github.com/tradingview/lightweight-charts/assets/12685308/77dfb684-a049-4b27-8ee5-28ff7e6e7830

CodeSandbox/JSFiddle/etc link:

Here's the minimal viable reproducable example: https://stackblitz.com/edit/nuxt-starter-ruhnxp?file=app.vue.

francisashley avatar Jan 20 '24 16:01 francisashley

My temporary solution is to suppress this with:

  window.onerror = function (message: string | Event): boolean {
    if (typeof message === 'string' && message.includes('Value is undefined')) {
      // Prevent the error from being logged in the console
      return true;
    }

    return false;
  };

https://github.com/tradingview/lightweight-charts/assets/12685308/95324bb9-e134-4ba8-aa7d-5a16bab70f77

francisashley avatar Jan 20 '24 16:01 francisashley

hello, I also encountered the same problem,any one can help to figure out the issue?

d8kzdzt avatar Feb 27 '24 13:02 d8kzdzt

The issue still exists in 4.1.3. Please fix this as it blocks also the correct execution of single and double click events :/

mourad1081 avatar Mar 05 '24 10:03 mourad1081