Activity indicators for visualizations


#1

Hi guys! I have an application with several widgets and I want to display some activity indicator (like a spinner or progress indicator) when a filter is applied in the app.

I managed to make it work but only when the application loads by attaching a callback to the .execute() just as described here: Getting data from the visualization. This way when the data arrives from the server I stop the indicator.

The thing is that it doesn’t work when using your Filter Control. How can I do this? Thanks in advance.


#2

Hi @ahmed, You have the first part right. Placing a callback for the .execute() method is the right way to go when the app loads for the first time.

Now for the the Filter Control (will be renamed to to Interaction Manager in the next release), what you need is create listeners for 3 of the FC events as described in the event section.

To display the loading indicator you have to do this:

fc.on('filter:added', showSpinner)
fc.on('filter:removed', showSpinner)

These events are triggered everytime a filter is registered and validated to be triggered (or removed) over the visualizations. They both return a list of the visuals that were affected so you have more control over what widget spinner you should display.

And to know when to stop it:

fc.on('filter:viz-finished', stopSpinner)

This event is triggered by visual, so you will receive one for each visual that was affected. It returns the visual id so you know exactly what spinner you should stop.

I hope this helps.


#3

I have two questions, the first one is that if instead of a spinner, can I use a progress bar as a loading indicator?

The second one is that if these events you mentioned also work for non visuals, I mean only for queries created that don’t render a visualization?


#4

Hello @diego

For your first question, this is possible. The requirement from the data engine is that the query API is asynchrounous (which is the case for Dremio and BigQuery) and that it provides an api to obtain the progress of the current query. Our team can help you create this custom provider if needed. We’ll be adding progress information for data engines that support this API.

For your second question the answer is yes. All queries go through the same set of stages, so every event that I mentioned before will be also triggered for queries that don’t render a visualization.


#5

I get it, so it must be supported by the data engine. Makes sense, otherwise there’s no way to know how far or close is the query to be completed. Thanks.