Closed workingbuddy10 closed 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.
@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.
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.
That's what I have done for now! I was looking for something standard, above than a hack/fuzzy logic.
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.