# Can visualisation plugins adjust query parameters?

**URL:** <https://discuss.elastic.co/t/can-visualisation-plugins-adjust-query-parameters/64340>\
**Category:** Kibana\
**Created:** [October 29, 2016, 2:46pm UTC](https://discuss.elastic.co/t/can-visualisation-plugins-adjust-query-parameters/64340 "2016-10-29T14:46:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cheloftus](https://avatars.discourse-cdn.com/v4/letter/c/f19dbf/32.png) [@cheloftus](https://discuss.elastic.co/u/cheloftus)\
**Post date:** [October 29, 2016, 2:46pm UTC](https://discuss.elastic.co/t/can-visualisation-plugins-adjust-query-parameters/64340/1 "2016-10-29T14:46:18Z")

</div>

I am writing a visualisation plugin in which I would like to have a button to fetch more buckets for the aggregation. I would also like to add a button to flip between Ascending/Descending order.

Is it possible for visualisations to modify the query/aggregation settings from within the rendered visualisation itself?

---

<div class="post-metadata">

**Author:** ![cheloftus](https://avatars.discourse-cdn.com/v4/letter/c/f19dbf/32.png) [@cheloftus](https://discuss.elastic.co/u/cheloftus)\
**Post date:** [October 29, 2016, 10:03pm UTC](https://discuss.elastic.co/t/can-visualisation-plugins-adjust-query-parameters/64340/2 "2016-10-29T22:03:01Z")

</div>

Ok, I got this working using the below code. But I'm pretty certain that's not the best way.

`
    const queryFilter = Private(FilterBarQueryFilterProvider);
```
 // Update aggregation parameters to fetch 5 more buckets
 var agg = $scope.vis.aggs.bySchemaName['MY_SCHEMA_NAME'][0];
 agg.params.size += 5;
 // Force a refresh by faking the filter events
 queryFilter.emit('update')
   .then(function () {
     queryFilter.emit('fetch');
   });

```
`

I did try `getAppState().emit('fetch_with_changes')` and `globalState.emit('fetch_with_changes')` to force the reload instead of faking the filter events. Both worked within the visualisation editor but not on a dashboard. Open to suggestions for a better method.

---

<div class="post-metadata">

**Author:** ![thomasneirynck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thomasneirynck/32/23313_2.png) [@thomasneirynck](https://discuss.elastic.co/u/thomasneirynck)\
**Post date:** [November 3, 2016, 8:00pm UTC](https://discuss.elastic.co/t/can-visualisation-plugins-adjust-query-parameters/64340/3 "2016-11-03T20:00:05Z")

</div>

hi @cheloftus,

a little late to the party.

There's no documented and stable API to do this in a Visualization-plugin. It's something we need to work on.

If you find your work-around is sufficient, I'd say keep it for now.

Feel free to open a feature-request in github too. It will help us get a better sense of priorities on what kind of API plugin-developers are looking for.

thanks,

---

<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:** [July 6, 2017, 1:34pm UTC](https://discuss.elastic.co/t/can-visualisation-plugins-adjust-query-parameters/64340/4 "2017-07-06T13:34:41Z")

</div>


