Hi, I’m trying to use the html plugin and I need to use a value coming from the query (alias “Rotation”).
On the html section I have a piace of code like this
I need to send my query value where I put ###HERE_MY_VALUE### in the above code.
Within the java script section I’ve been able to get my query value in this way:
let arrayHxObj = ctrl.data[0].rows;
myvalue = arrayHxObj[0]["Rotation"];
Thanks @mattabrams, I don’t want to use text panel but Html plugin. Moreover even on these link, I can see how to show the value (what I’m already able to do). I need to use this value within the html code in order to rotate an object to show
this one HTML plugin for Grafana | Grafana Labs
I’m able to show value directly in html, but I need to use it in the middle of the code as I posted above. Thanks a lot
This is not the problem. I’m able to see the value within the panel, if I want it. What I’m not able to do is to pass it for more action within html code. If you look at my first message I need to pass the value where I wrote ###HERE_MY_VALUE###, and it is needed in order to make a rotation of the element. I cannot find the correct syntax to bind the js section to the html one.
Bytheway, HTML plugin is not not text plugin
@donatod you may be best off reaching out to the plugin developer directly (either via email or the plugin’s GitHub repo). This isn’t a very widely used plugin, and I suspect that there won’t be many people on this forum who are familiar with it.
My uninformed take is that what you’re trying to do is probably not possible. I think you need to set the HTML element’s rotation property in the JS code, rather than trying to inject a value into the HTML as you’re attempting to do.
Thanks Svet, I tried to contact him by email but no answer, yet. Honestly I don’t know where to start from, setting the HTML elements rotation property in the JS code. Any help on how to do it?
Hm…cautious to delve into this as I really have little idea how that plugin works. But maybe try this:
In the HTML, give the element you want to modify a unique ID. E.g. <path id="thePath" fill=...
In your JS, identify the element using e.g. let thePathElement = document.getElementById('thePath');
Modify its property with something like thePathElement.transform.rotate = [myvalue, 0, 0];
This last one is a complete guess and almost certainly wrong. I’d suggest exploring the element’s actual properties (and figuring out what needs setting) using your browser’s dev tools.
Note that I noticed in the HTML plugin docs it states “HTML & CSS is encapsulated in a shadow root and will therefore not “leak” outside the control.” - depending on what exactly this means, the above may not actually work.
Also…I’m not quite sure what you’re using the plugin for, but if it’s showing and manipulating an SVG then I’d say that these days you probably have better options than a plugin which had a single alpha release 2 years ago and appears to be unmaintained. Check out e.g. ACE.SVG plugin for Grafana | Grafana Labs which is my go-to, or HTML graphics plugin for Grafana | Grafana Labs (which I haven’t used but also looks nice). Or SVG plugin for Grafana | Grafana Labs, which the HTML plugin you’re using appears to be based on.
Anyway, I’ll give a look at the plugins you suggest, I agree with you on using some more updated plugin. What I need is to have a page with some alarms led (green/red) and a button for each one in order to reset it via HTTP/REST (with a pop up confirmation).
Do you think that thees SVG plugin would be the right choose?
I would say that all of these plugins do something quite similar, so I think the others should work for your requirements also (i.e. with buttons that trigger HTTP requests when clicked). Anyway, if the one you have now gets the job done for you then maybe there’s no rush to migrate.
Sorry @svetb, In some case because of the result I get, I need to add a vertical scroll bar. I made some test using css section, but always I get a fix visible bar. Any tip?
I’m sorry, that’s not something I have any experience with. I suspect the answer is somewhere out there on the Internet. (I don’t think what you need here is specific to Grafana or the HTML plugin…probably more of a general CSS question)