-
I am using Grafana 11.3 with the HTML Graphics plugin 2.1.1. I simply want to include the value of a dashboard constant variable in the HTML/SVG body. Using ${VariableName} displayed as exactly that, ${VariableName} when I expect the value to be displayed. Below is my test panel:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
This plugin doesn't replace the HTML content with the variables. You can manually do it in the onInit or onRender code, though. The easiest thing to do is to add: htmlNode.innerHTML = htmlGraphics.props.replaceVariables(htmlNode.innerHTML); For a bit more control you could manually add the HTML in the const targetElt = htmlNode.querySelector("div > div");
targetElt.innerHTML = htmlGraphics.props.replaceVariables(`
<b>ALT No.: </b>\${AltIDNo}<br>
<b>CUSTOMER: </b>\${Customer}<br>
<b>LOCATION: </b>\${Location}`); The examples above use Alternatively, you could use the built-in |
Beta Was this translation helpful? Give feedback.
-
I stuck with the HTML Graphics plugin and used your example, and it worked perfectly! Thank you!! I figured it was something simple. I wanted to stick with that plugin because it seemed to give more options for creating the effect I wanted, namely, to have the text float over part of the image, like this: The Text plugin didn't seem to do that effectively, although I didn't really dig deep on why. And thank you for the quick reply! |
Beta Was this translation helpful? Give feedback.
This plugin doesn't replace the HTML content with the variables. You can manually do it in the onInit or onRender code, though.
The easiest thing to do is to add:
to the
onInit
section.For a bit more control you could manually add the HTML in the
onInit
section:The examples above use
htmlGraphics.props.replaceVariables(...)
, which is the same asgetTemplateSrv().replace(...)
.https://gapit-…