Visualization Request Handlers

edit

Request handler gets called when one of the following keys on AppState change: vis, query, filters or uiState and when timepicker is updated. On top of that it will also get called on force refresh.

By default visualizations will use the courier request handler. They can also choose to use any of the other provided request handlers. It is also possible to define your own request handler (which you can then register to be used by other visualizations).

courier request handler

edit

courier is the default request handler which works with the default side bar editor.

none request handler

edit

Using none as your request handles means your visualization does not require any data to be requested.

custom request handler

edit

You can define your custom request handler by providing a function with the following definition: function (vis, appState, uiState, searchSource) { ... }

This function must return a promise, which should get resolved with new data that will be passed to responseHandler.

It’s up to function to decide when it wants to issue a new request or return previous data (if none of the objects relevant to the request handler changed).

import { VisFactoryProvider } from 'ui/vis/vis_factory';

const myRequestHandler = (vis, appState, uiState, searchSource) => {

  return new Promise((resolve, reject) => {
     const data = ... parse ...
     resolve(data);
  });
};

const MyNewVisType = (Private) => {
  const VisFactory = Private(VisFactoryProvider);

  return VisFactory.createAngularVisualization({
    name: 'my_new_vis',
    title: 'My New Vis',
    icon: 'my_icon',
    description: 'Cool new chart',
    requestHandler: myRequestHandler
  });
}

VisTypesRegistryProvider.register(MyNewVisType);