charting-library-examples icon indicating copy to clipboard operation
charting-library-examples copied to clipboard

getBars method is not getting called.

Open sumanth1462 opened this issue 1 year ago • 11 comments

I am trying to integrate tradingview into flutter app. I am using in app webview of flutter and javacript handlers for communication.

{"name":"PNB","full_name":"PNB EQ","ticker":"5676","description":"","daily_multipliers":["1"],"delay":0,"type":"common_stock","session":"0915-1530","exchange":"NSECM","listed_exchange":"NSECM","timezone":"Asia/Kolkata","format":"price","pricescale":100,"minmov":1,"fractional":true,"minmove2":0,"has_intraday":true,"supported_resolutions":["1","5","30","60","1D","1W","1M"],"intraday_multipliers":["1","5","30","60"],"has_seconds":false,"has_ticks":true,"has_daily":true,"has_weekly_and_monthly":true,"weekly_multipliers":["1"],"monthly_multipliers":["1"],"has_empty_bars":false,"visible_plots_set":"ohlcv","volume_precision":0,"data_status":"streaming","expired":false,"expiration_date":0,"currency_code":"INR","original_currency_code":"INR"} - this is the data that is passed to resolveSymbol . After this step, there are no errors visible and also getBars is not being called.

sumanth1462 avatar Sep 04 '24 05:09 sumanth1462

You would need to provide the version of the library you are currently on along with full logs attached as a text file by enabling then in Widget Constructor (debug: true).

romfrancois avatar Sep 04 '24 05:09 romfrancois

version is v28.0.0 tradingviewlogs.txt

sumanth1462 avatar Sep 04 '24 06:09 sumanth1462

I'm facing an issue where the getBars callback is not being triggered after the resolveSymbol function completes successfully in my TradingView integration. The logs confirm that the symbol is resolved ("Symbol resolved"), but no subsequent logs indicate that getBars is called. Instead, I see a log stating, "Processing pending subscribers, count=2," suggesting that there are pending subscribers but no data is fetched. Structure of resolveSymbol is available in above message and logs attached.

I'd appreciate any insights on why getBars isn't being triggered or if there are specific steps I should follow to ensure it executes properly. Thank you!

sumanth1462 avatar Sep 05 '24 09:09 sumanth1462

Would you be able to record a video of what's happening?

Looking at the logs it seems that the library is not requesting any data.

Ideally you should see something similar to

Leftmost subscriber requires 329 bars prior 2024-09-05T09:44:28.744Z Requesting data: [2024-06-26T13:03:51.820Z ... 2024-09-05T09:44:28.744Z, 329 bars]

romfrancois avatar Sep 05 '24 09:09 romfrancois

https://github.com/user-attachments/assets/d21fe7fe-e55a-445f-bf64-b4e3673fa2f1

In video, we can see the logs and also the loading of chart.

sumanth1462 avatar Sep 05 '24 10:09 sumanth1462

@romfrancois, any update on the query raised ?

sumanth1462 avatar Sep 16 '24 12:09 sumanth1462

@sumanth1462 could you please share your getBars implementation?

GeorgiiMatveev-tv avatar Oct 01 '24 10:10 GeorgiiMatveev-tv

Hi @GeorgiiMatveev-tv ,

Thanks for reaching out! Here's a quick clarification regarding the getBars implementation:

I've attached some snippets from our code that show how we're connecting TradingView from Flutter using an in-app WebView. The snippets follow the execution order:

chart_initiate: We load the TradingView HTML within our WebView. Once it loads, Flutter triggers the start handler, where we create the options widget. As you can see, we pass the path, datafeed, and container id here.

datafeed_obj: This snippet shows the structure of our datafeed object. I’ve included the implementations of resolveSymbol and getBars.

flutter_controller: This controller handles the data request made by the datafeed object. When the datafeed requests it, the controller fetches the necessary data and sends it back.

Up until the resolveSymbol part, everything works as expected. However, getBars is supposed to request the range and interval of the needed data, but that step is not happening as intended. @sumanth1462 has included the necessary logs throughout the connection and request process in the previous messages.

Let me know if you need more details. 1_chart_initiate 2_datafeed_obj 3_flutter_controller

ashlin-utrade avatar Oct 01 '24 14:10 ashlin-utrade

The logs that you've shared above show that the library received the Symbol Info from resolveSymbol. So it should call getBars next unless something in the LibrarySymbolInfo is invalid.

Suggestions: The type is 'common_stock' but that is not a possible option: https://www.tradingview.com/charting-library-docs/latest/api/modules/Charting_Library#symboltype, could you please adjust and check if it changes anything?

Also you could test against our demo datafeed to make sure that the issue is not with the flutter layer: https://github.com/tradingview/yahoo_datafeed

GeorgiiMatveev-tv avatar Oct 10 '24 16:10 GeorgiiMatveev-tv

@GeorgiiMatveev-tv

Even after hardcoding the type as "stock," the getBars function is still not being triggered. Additionally, we're unable to generate API keys for the demo datafeed, as the website mentioned seems to be down. Could you please advise on any alternative methods to proceed, or if there might be any additional steps we should take to resolve this issue?

Screenshot 2024-10-11 at 4 48 14 PM

ashlin-utrade avatar Oct 11 '24 11:10 ashlin-utrade

Hello @ashlin-utrade generate API keys for the demo datafeed, as the website mentioned seems to be down.

Apologies for the late reply, please try using the demo datafeed from here, might be an easier path.: https://www.tradingview.com/charting-library-docs/latest/saving_loading/save-load-rest-api/#storage-example

GeorgiiMatveev-tv avatar Nov 04 '24 13:11 GeorgiiMatveev-tv