# Code/JS API to refresh a visualization

**URL:** <https://discuss.elastic.co/t/code-js-api-to-refresh-a-visualization/93431>\
**Category:** Kibana\
**Created:** [July 17, 2017, 4:50pm UTC](https://discuss.elastic.co/t/code-js-api-to-refresh-a-visualization/93431 "2017-07-17T16:50:09Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![bishwajeet](https://avatars.discourse-cdn.com/v4/letter/b/ec9cab/32.png) [@bishwajeet](https://discuss.elastic.co/u/bishwajeet)\
**Post date:** [July 17, 2017, 4:50pm UTC](https://discuss.elastic.co/t/code-js-api-to-refresh-a-visualization/93431/1 "2017-07-17T16:50:09Z")

</div>

Hello. I am writing a custom Kibana plugin.

When the parameters in the editor change and somebody pushes the play button, how do I refresh my visualization, I am not getting notified when parameters or the search filter changes. I tried looking at the plugins listed as examples in the known plugins page - [https://www.elastic.co/guide/en/kibana/current/known-plugins.html](https://www.elastic.co/guide/en/kibana/current/known-plugins.html) .

Most of them, do not change visualization unless you refresh the page. Is there an example which I could look into to better understand how the change in parameter is handled in a proper 5.5.0+ compatible plugin.

---

<div class="post-metadata">

**Author:** ![ppisljar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppisljar/32/11588_2.png) [@ppisljar](https://discuss.elastic.co/u/ppisljar)\
**Post date:** [July 17, 2017, 5:12pm UTC](https://discuss.elastic.co/t/code-js-api-to-refresh-a-visualization/93431/2 "2017-07-17T17:12:48Z")

</div>

all the core\_plugins visualizations (the ones provided out of the box) refresh on clicking the play button, so maybe its best to look there ...

what branch are you developing on ?

---

<div class="post-metadata">

**Author:** ![bishwajeet](https://avatars.discourse-cdn.com/v4/letter/b/ec9cab/32.png) [@bishwajeet](https://discuss.elastic.co/u/bishwajeet)\
**Post date:** [July 17, 2017, 5:28pm UTC](https://discuss.elastic.co/t/code-js-api-to-refresh-a-visualization/93431/3 "2017-07-17T17:28:16Z")

</div>

True. All 'core' plugins do refresh on clicking the play button. But you probably have an observer/event which captures that and calls your code so it could react to it. Can someone point me out to a specific code snippet at github where this event happens. I tried looking but it is not clear to me how it is being done ? There does not seem to be much documentation.

I am on the branch tagged v5.5.0 at [github.com/elastic/kibana](http://github.com/elastic/kibana) repo.

---

<div class="post-metadata">

**Author:** ![ppisljar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppisljar/32/11588_2.png) [@ppisljar](https://discuss.elastic.co/u/ppisljar)\
**Post date:** [July 17, 2017, 5:35pm UTC](https://discuss.elastic.co/t/code-js-api-to-refresh-a-visualization/93431/4 "2017-07-17T17:35:04Z")

</div>

and i guess you are using template vis type ?

```auto
$scope.$watch('vis.params', () => {
   // params got updated
});

```

i think something like this should work. let me know how it goes.

---

<div class="post-metadata">

**Author:** ![ppisljar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppisljar/32/11588_2.png) [@ppisljar](https://discuss.elastic.co/u/ppisljar)\
**Post date:** [July 17, 2017, 5:38pm UTC](https://discuss.elastic.co/t/code-js-api-to-refresh-a-visualization/93431/5 "2017-07-17T17:38:01Z")

</div>

and tag cloud is probably the simplest vis to check:

> <https://github.com/elastic/kibana/blob/5.5/src/core_plugins/tagcloud/public/tag_cloud_controller.js>

---

<div class="post-metadata">

**Author:** ![bishwajeet](https://avatars.discourse-cdn.com/v4/letter/b/ec9cab/32.png) [@bishwajeet](https://discuss.elastic.co/u/bishwajeet)\
**Post date:** [July 19, 2017, 3:39pm UTC](https://discuss.elastic.co/t/code-js-api-to-refresh-a-visualization/93431/6 "2017-07-19T15:39:58Z")

</div>

Thanks. I got it working through the multiwatch since we need to monitor both 'esResponse' and 'vis.params'

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 16, 2017, 3:40pm UTC](https://discuss.elastic.co/t/code-js-api-to-refresh-a-visualization/93431/7 "2017-08-16T15:40:31Z")

</div>

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