sassoftware / sas-visualanalytics-thirdpartyvisualizations

The data-driven content object enables you to display your data in a custom third-party visualization, within your SAS Visual Analytics report. The third-party visualization can be authored in any JavaScript charting framework, such as D3.js, Google Charts, or CanvasJS. The visualization in a data-driven content object receives its data query from SAS Visual Analytics, and so it interacts with filters, ranks, and object actions in the same way as the other objects in your report. For information about creating third-party visualizations for data-driven content, see Programming Considerations for Data-Driven Visualizations in SAS Visual Analytics: Reference.
Apache License 2.0
39 stars 61 forks source link

setOnDataReceivedCallback is executed twice in a VA-PopUp-Window #50

Open pw182162 opened 3 years ago

pw182162 commented 3 years ago

Hi! We have an issue in the VA-PopUp-Window (hidden Report). The setOnDataReceivedCallback is executed twice. First call with the data from the previous execution and the second with the new data. Unfortunately it is not deterministic which one will be executed first. Most of the time the "order" is correct, but not always. So it's like 10% chance that you get a wrong data. Any Idea how to workaround this issue?
setOnDataReceivedCallback

rluppi commented 3 years ago

@pw182162 , the callback function should execute only once, every time something changes in the received message, such as data, column, parameter, etc. What action(s) are you performing in the VA report that is triggering those changes and therefore sending different messages to the DDC object? Also, remember that VA queries are performed asynchronously, so if the final value is a result of multiple calculations (specially those involving parameters), it may be the case that the calculated value assumes intermediate results until all branches are fully calculated, and this could trigger multiple messages, but the last one should be the correct one.

rluppi commented 3 years ago

Please, ignore my previous message. After re-reading your message I think I know what's going on. When the popup window (hidden page) opens, it displays the old information because this had been cached last time the window was opened. The fact that the window is reloaded sends a message to the DDC with the current (old) value. When the new value is refreshed a new message is sent to the DDC. I don't know if there is a better way of doing it, but apparently in your particular case you will always get two messages, where only the second one is the correct one. Due to the asynchronous nature of this processing, we would need to try a combination of semaphore and timer in your callback function to make sure the first one is ignored if a second message arrives in a timely fashion.

pw182162 commented 3 years ago

@rluppi, thank you for confirming this. I figured out how to do a workaround. It works for me this way: workaround