Closed danellis10 closed 1 month ago
Hmm, this might be related to https://github.com/nline/nline-plotlyjs-panel/issues/7. I'll investigate this.
I think this will fall under the category of user-error. I was able to reproduce the behavior in the stock panels and figured out the issue I was doing in the configuration (I had a filter wrong).
I reopened this because I'm running into a similar issue that doesn't seem to have a workaround (or I don't know how to make it work). I have a repeated panel based off of a Dashboard variable called "ID" that is multi-value. Let's say the values selected are 15 and 16. I want the script section to see "15" for one panel and "16" for the second panel. Currently, $ID is [15,16] in each panel script. For non-repeated panels, this is the correct behavior. My previous workaround was to use grafana filter to filter on ID=$ID in the Panel Results Filter so the script would only see IDs with 15 for the first panel and 16 for the second panel. This worked great when I wanted to have each panel ONLY have results for 15 or 16.
My new problem is that I want each panel to process data for both 15 and 16 at the same time, but to do special work for 15 in the first and 16 for the second. Think about a simple case of wanting to chart two series in each panel on top of each other, but you want the first series bolded in the first panel, but the second bolded in the second. The script needs the complete set of data, but also needs to know what the repeated panel selection is.
How do I get the $ID to be passed into the script section properly for these repeated panels? I thought about passing in/expanding $ID into the layout and saw that variables were implemented in v1.5 of the plug-in. This is a bit sketchy and unclean, but is doable. Is there a more proper way to do this?
I think you might have to break up the array. You can inspect the variables
object in the Script section and apply the layout you want there. The yaml/json fields are intended to be static for the most part (though you can use Grafana variables there inplace).
Can you confirm you were able to solve this?
Not in an elegant way.
I have my Datasource A which has all my data in a CSV file (infinity plugin). I have a Dashboard variable called ID which is multi-value ([15,16] in this case). When each panel gets rendered, each panel sees the variable.ID as [15,16], so the script can't view variables.ID to determine which instance it is. There is one panel for 15 and one panel for 16. Since I need data for both 15 and 16, I can't directly filter the datasource A to only 15 or 16.
The one workaround I found is to create a Datasource B that sets a value to 15 or 16 respectfully. In infinity datasource, this was done through a CSV Inline data source where I create an inline CSV with a single column of PanelID for the headers and a single data row of $ID. This gets made visible into the script as data.series[1].fields[0].values.buffer[0].
Inside the script, I can iterate over all the data and perform special actions based on what repeated panel it is.
It would be very nice to have the repeated panel instance and the untouched dashboard variable available to the script and not just at the grafana filter/datasource level. I am on Grafana 8.3.
Thanks, Dan
On Wed, Aug 7, 2024 at 12:56 PM Jackson @.***> wrote:
Can you confirm you were able to solve this?
— Reply to this email directly, view it on GitHub https://github.com/nline/nline-plotlyjs-panel/issues/8#issuecomment-2274242176, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZRLI6FJLIFY5RJVLRDBHETZQJ3WHAVCNFSM6AAAAAAYPC3TDWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENZUGI2DEMJXGY . You are receiving this because you modified the open/close state.Message ID: @.***>
Ah, is it possible for you to upgrade Grafana? I wouldn't be able to test your use case given all the changes that have been made since then - 8 is quite old.
Hi, this is still an issue with Grafana 11. At its essence, for a repeated plotly panel, I have no ability within the plotly script to determine which instance of the repeated variable panel I'm in. If I have a dashboard variable call server with A and B values, and choose a plotly panel to repeat on the server variable, I correctly get two repeated panels, but the script has "variable.server" variable set to both repeated instances, but no other means to distinguish the "instance" of the panel. There should be a means from within the script to get both the full selection (which is what its doing today) and the instance.
Hmm, I think could be a bit out of scope for the panel itself.
Is this not what you're after?
https://github.com/user-attachments/assets/c8bed925-773b-4f0b-9c79-0d2da9d95a54
This exposes the panel instance variable to the Layout editor (which is cool), but I need that value to be visible in the javascript as well so I can process the whole of the data.series differently. In your example, the query0 is getting set appropriately for each panel instance, but query0 in javascript is an array of selected values (two in my example above).
Yeah this is tricky. I have a fix for it in the next patch! I'll add a replaceVariables
function that picks up the scope.
https://github.com/user-attachments/assets/d4ec6107-e8b5-41a3-8559-8b2200fd5d22
@danellis10 Please try the utils.replaceVariables($variable)
included in 1.8.1.
Grafana allows you to mark a panel as "repeated" based on selections in a variable. If you a variable called Server with values of server1, server2, server3, etc., the panel gets dynamically repeated, one for each variable value. This works great in Grafana itself and if you include "Server: $server" in the title field for the panel, each dynamically created panel will have the correct title (Server: server1, Server:server2,... ).
The plug-in doesn't seem to support this and each dynamically created panel will have the complete variable selection (if you selected all three servers, each panel will have variables.server equal to ['server1', 'server2', 'server3'] and each panel will will have same data set.
Is there a way to have variables.server only reflect the intended value for repeated panels?
See below, the title is correct (grafana passes the variable correctly), but the data set is still all three servers. Is there a workaround for this or could the plugin be updated to only set variables.server to the single instance for repeated panels?