Can visualisation plugins adjust query parameters?


(Cheloftus) #1

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?


(Cheloftus) #2

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.


(Thomas Neirynck) #3

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,


(system) #4