Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't update chart with new data came from server! #402

Open
moor-zaa opened this issue Dec 4, 2024 · 0 comments
Open

Can't update chart with new data came from server! #402

moor-zaa opened this issue Dec 4, 2024 · 0 comments

Comments

@moor-zaa
Copy link

moor-zaa commented Dec 4, 2024

I am integrating the TradingView Advanced Charting Library into my Next.js application and have encountered the following issues:

Chart Data Updates:
When my component receives new OHLCV data, the chart does not update dynamically. I am passing the new data to the chart at regular intervals (every 10 seconds), but the chart does not reflect these changes unless it is reloaded, which affects user experience.
Screenshot 2024-12-04 120246

Timeframe Selection Issue:
When switching the chart's timeframe to daily or weekly, the chart does not display the data correctly. The data either appears misaligned or does not load at all.
Screenshot 2024-12-04 115933

Steps Taken:

Dynamic Data Updates:

I am using a custom dataFeed implementation for the TradingView chart, where new OHLCV data is passed at regular intervals (10 seconds).
The getBars method retrieves historical data, filtering it based on the requested period and returning it in the required format.
The subscribeBars method handles real-time updates by sending the latest bar to the chart via onRealtimeCallback.
The data feed is updated dynamically using the resetData method and assigning the updated data feed to the chart when the ohlcvData changes.
Timeframe Management:

Supported resolutions are defined in the onReady method and symbol resolution settings, covering intraday, daily, and weekly intervals (e.g., 10, 15, 30, 60, 1D, 1W).
The chart’s data feed and bars are structured to support these resolutions, including daily and weekly intervals.
Timezone and session settings are configured to handle 24x7 data, with UTC timezone for consistency.
Reinitialization and Cleanup:

The widget is initialized with the TradingViewWidget constructor, using the provided chartOptions and theme.
To prevent memory leaks, the widget is removed during component unmounting or navigation changes.
Theme Switching:

When the theme is changed, the changeTheme method updates the chart dynamically.
Despite these implementations, the chart does not update with new data dynamically, and the daily/weekly timeframes do not display the data correctly.

Could you please review this implementation and suggest any changes or corrections?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant