Kibana visualizations is not being updated

hi team, please help me solve the issue. My custom plugin changes saved object of native visualization after user clicks. So issue is when user click on dashboard , then script edits saved object of native kibana visualizations on that dashboard(f.e Pie chart), and then it is not being updated on the dashboard. And to see changes i need to reload page. Is there any way to resolve it to be updated after user click button?

That's a non-trivial thing to do from a custom plugin. Dashboard is not explicitly exposing functionality for this. Can you share your code? This will make it easier to suggest possible ways.

General workarounds I can think of:

  • Reload the page from within your plugin when the visualization needs to get updated.
  • Set a sensible value for auto-refresh of the dashboard, then the dashboard will update itself from time to time

Sure, but there are too much code to provide here. Is it possible to organize sharescreening session via teamviewer or something like that?

You could put your code on Github

Hi Joe, i pushed code to github with ref kibana_plugin (routes.js). So logic is :

  1. user press the button
  2. my POST endpoint makes changes to saved object
  3. then after refresh button the saved object should update its visualization

item 3 is not being completed.

Do you only want to update your own visualization or every visualization on the current dashboard?

In the first case you should just handle that within your component (fetching data from the server and updating react using react state).

In the second case it gets a little hacky because there is no API specifically for that. A workaround would be to set the auto refresh to a very low number (e.g. once second), then wait a second and set it back. How exactly that works depends on the version of Kibana you are targeting though.
A simple approach that definitely works is to just call window.location.reload() in that case.

Hi Joe, I`m afraid it didnt help. Case was like:

  1. Dashboard loaded as is.
  2. I pressed button which changes saved object of my kibana native visualization.
  3. Then there was no changes after 5 secocd had passed. Only my custom visualization changed, but not native. As native i used pie chart and horizontal bar chart.

DId you try calling window.location.reload() when you want to update?

Yes, i did, but it reloads all the page in browser which is not to architecture of kibana. Kibana reloads visuzlizations without reloading a page

Yes, as I mentioned above there is no API for triggering a refresh without page reload from within the visualization. I also mentioned a workaround. When you tell me which version of Kibana you are targeting I can give you a code snippet.

Hi Joe, my Kibana version is 6.7.3

In that case you can get $rootScope injected in https://github.com/webmasterThomas/kibana_plugin/blob/master/public/app.js
and call $rootScope.$broadcast('fetch') to refresh - that should be propagated everywhere.

can you push snippet here? cant quite understand where i should put this strings

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.