Variables
Use the context.grafana.replaceVariables()
function to replace dashboard and global variables.
const email = context.grafana.replaceVariables("${__user.email}");
You can get familiar with three types of variables in our Grafana Crash Course.
Replace Variables
In the following example, we replaced the series's name with a value from the variable.
Example
docs/volkovlabs-echarts-panel/js/replace.js
loading...
Update Variables
You can update dashboard variables with event handlers, where
name
is the name of the variable. Addvar-
to update the variable value in the URL.value
is the updated value.
context.panel.chart.on("click", (params) => {
context.grafana.locationService.partial({ "var-name": value }, true);
});