I have a chart that pulls its data from an api… When the data is updated, the chart is not refreshing. The only way I can get it to refresh is to refresh the page which is not good… How can I get the data to refresh when a record is added through an api? In my mind there should be an action in the action menu to refresh chart based on workflow but there is not? Ideas?
Hi @bkhoward2001 - have you tried putting the chart in a group and in the workflow to add data via API happens, do a Group Reset on the Group that contains the chart.
Yes I have, but doesn’t seem to work…
Untested idea …
Use a custom state as the source of the chart data, and use a workflow to update the custom state from the API.
@mishav mishav, you are the best!
I am confused with a basic thing… I have placed a chart object on the page. I have them set a custom state on that chart of sTaskStat (number). However, I am not sure how to set this up for the chart to use the custom state… Can you please go to my example at:
and show me how to set the chart to pull the custom state? I know how to get the custom state set within the workflow so that shouldn’t be an issue… Thanks @mishav
I just looked at your design. You have Line/BarChart A in Group “Create Task Group”. For my recommendation, Line/BarChart A would be in it’s own Group using “Group elements in a Group” (and that Group, ie “Group A” would be in “Create Task Group”). That group (“Group A”) would get reset in the workflow (not the “Create Task Group”). Is this the implementation you tried already and it didn’t work (or were you resetting “Create Task Group”?
No I have already tried what you are suggesting… I had four charts in a group as you stated, and the reset the group in the workflow did not work…
Hi @bkhoward2001, can you clarify the example:
- which API are you using for the chart data?
- which workflow step(s) do you want to refresh the chart’s data source?
If you setup the chart to load the data you want, it is more straightforward to switch to a custom state.
The custom state can be set to a list of the same type as the API result, which probably isn’t number.
The API is TaskStats… I have put it into the example. I want the event to be when that group is visible because I will have a group(hide/show) strategy all on one page. So whenever, that group (Create Task Group) is shown or unhidden I want it to get fresh data for the chart… I put as much info as I can into the example… Give it another look.
I’ve updated the app:
- Added a button to run the workflow step to refresh the chart (you can put that anywhere else)
- Added the same workflow step to page loaded event.
It doesn’t work, because Bubble is caching the API result. So you need a way to bypass the cache, i.e. be able to make the API request different at the time you want to refresh.
When you add a parameter for that, it should work okay.
I added the parameter to use the current datetime extacted as unix, but it still didn’t work…?
It worked great, from the refresh button : )
I copied the same workflow step to the two workflows for add task (Button Save Task is clicked) and delete task (Delete Task is clicked), now it updates when appropriate.
You might still want to offer a refresh button to the user, if for example, updates to the tasks can happen from another page or by another user.
@mishav You have outdone yourself again!!! Thank you so much. You are the best.
This topic was automatically closed after 70 days. New replies are no longer allowed.