amcharts / amcharts5

The newest, fastest, and most advanced amCharts charting library for JavaScript and TypeScript apps.
Other
353 stars 95 forks source link

Bug : Indicator class method render multiple time #1736

Closed workingbuddy10 closed 1 month ago

workingbuddy10 commented 1 month ago

I have created multiple custom indicators, but one thing was common in that : prepareData gets call 4 times. Even though :

I just clicked on the custom indicator and prepareData method was called 4 times.

Ideally which is not the good practice. And in my case I don't use the data for custom indicators from the stockSeries /valueSeries as those indicators don't use the OHLCV data. I fetch it from an api. So if the prepareData method is running 4 times Initially then it is making 4 API calls.

image

martynasma commented 1 month ago

This question was reviewed by amCharts staff and was determined neither a) bug nor b) simple question that can be answered without doing custom development or reviewing user code.

I'm sorry, but we won't be able to answer your question here.

If you have an amCharts support subscription, we suggest contacting our helpdesk. If you don't, you might consider acquiring one. For more details on procuring support please refer to this page.

workingbuddy10 commented 1 month ago

@martynasma It is not a custom code.

you can go on this amcharts doc https://www.amcharts.com/docs/v5/tutorials/creating-custom-indicators-for-a-stock-chart/ And just add aconsole.log("coming here") in prepareData method and then add that custom indicator on chart.

You will see the coming here is getting printed 4 times.

Is that a good thing?

As prepareData is a core method for the logical operations of the indicators, and it is getting rendered multiple time.

martynasma commented 1 month ago

Well, it is what it is. I'm afraid we won't be able to underlying structure.

If multiple invocation creates an issue for you, you may implement some kind of flag property in your class to log whether init stuff has already been done and simply ignore subsequent calls.

workingbuddy10 commented 1 month ago

That's what I have done for now! I was looking for something standard, above than a hack/fuzzy logic.