XY Chart: Updating Dashboard Variable Value on Point Click

I want the value stored in “solution” column to be saved in the “selected_solution” variable when I click on a point in the XY Chart. I saw an idea to configure a datalink, but nothing happens when I click. Am I setting up the link incorrectly or would this method actually not work? I based it on this example: Grafana
my datalink is: localhost:3000/d/cdupzpsya0c8wa/optimizer-dashboard-with-variable?orgId=1&var-selected_solution=${__value.numeric}

Notes:

  • I am using the Infinity Data Source plugin to read CSV.
  • Grafana Version: 11.1.3
  • OS: Ubuntu 22.04.4 LTS

you have created a variable named “selected_solutin” constant or custom type?

start your link with: d/cdup…

when you hover over the link, the variable is filled with the value?

for testing, disable the “open in new tab” switch.

create a text panel where you can check the variable.

Jo

1 Like

Hi Joachim,

Thank you for your response! :smile:

Ultimately, I managed to make it work.
I added a datalink in this format: http://localhost:3000/d/id…/optimizer-dashboard-with-variable?var-selected_solution=${__data.fields[‘solution’]} with the title “SELECT THIS SOLUTION”. This way, when I clicked on a point in the XY Chart and selected “SELECT THIS SOLUTION”, it changed the value of the variable selected_solution.
To answer your question, the variable was a query, and I was using a csv file from infinity plugin to obtain the “solution” column, which contained all possible solution options.
image

This way works, but I wanted it to modify the value of selected_solution as soon as I clicked on the point. I managed to do this using a scatter plot from the Business Chart plugin.
The code was something like this:

context.panel.chart.on("click", (params) => {
context.grafana.locationService.partial({ "var-selected_solution": params.data[2] }, true);
});

Where params.data[i] allows access to the values associated with that point in any column (i is the index of the column in the table).

Thank you for your response! I hope this also helps other people who may have this question in the future.

1 Like