Skip to content

Is there an event that fires only when dashboard variables are updated? (and not when the panel is resized) #148

Answered by ZuperZee
aduda9 asked this question in Q&A
Discussion options

You must be logged in to vote

No. There aren't any events for just variable changes. You could store the previous variable value and manually check if it has changed.

only-update-on-variable-change1.mp4

onInit

let myVar = htmlGraphics.props.replaceVariables("$var");

function doSomething() {
  console.log(`Doing stuff (${myVar})`);
}

htmlNode.addEventListener("panelupdate", () => {
  const newMyVar = htmlGraphics.props.replaceVariables("$var");

  if (myVar !== newMyVar) {
    myVar = newMyVar;
    doSomething();
  }
});

Dashboard JSON Model

{
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": {
          "type": "grafana",
          "uid": "-- Grafana --"
        },
        "…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@aduda9
Comment options

Answer selected by aduda9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants