Skip to main content

Grafana Events

Grafana uses an event bus to publish application events for notifying different parts of Grafana when the user interacts with the chart. Business Charts panel can react to these actions by subscribing to one or more events.

Extended result object

The Business Charts 5.0.0 allows you to unsubscribe from events to avoid memory leaks by returning an extended result object.

Predefined Events

A full list of events is available in our Grafana Crash Course.

Subscribe to events

To subscribe and unsubscribe from events, you can create an extended result object.

const subscription = context.grafana.eventBus.subscribe({ type: 'data-hover' }, () => {
console.log('React to Data Hover')
})

return {
version: 2,
config: { notMerge: true },
option: {},
unsubscribe: () => {
subscription.unsubscribe();
console.log('Unsubscribed');
}
}