Beginners question on plugin API constructor and methods

Hi everyone!

I’m new to Grafana and also to ES6 / advanced JS programming in general. With the help of the sample panel plugins I managed to write my own panel plugin… Well, actually it’s more a stripped-down copy of panel which I extend for some special purpose (engine performance maps).

So far so good. But now I really would like to understand a bit more how things work. There are two basic questions:

  • Which are the parameters of the constructor of my panel controller class? Maybe I’m missing some basic understanding of ES6 OOP mechanism here. Each panel plugin code I looked at has similar, but not the same parameters here. Are they documented somewhere?
  • Most of the controller class methods have their purpose in being triggered by certain events. This is comprehensible. But as it seems there are other methods, like link() for example, which need to be overwritten in some cases. Are these methods documented somewhere?

Maybe my questions are really dumb… sorry for that.


  • Panel controller’s constructor takes AngularJS dependencies. Usually, it’s just $scope, $injector which is a minimum required, but you may want to use something else, like $rootScope or any angular service, or grafana services like templateSrv, backendSrv, dashboardSrv, timeSrv or any other. It depends on your needs.
  • link() method is used for override directive’s link() function. You may use it for implementing custom panel rendering.
1 Like

Hi Alexander,
thanks so much! Angular was the missing link…
So all these parameters beginning with $ reference a Angular service by name. This explains a lot.

Yes, AngularJS internal services are usually starting with $.