-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Stat: Fix data links that refer to fields #80693
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thanks @ajwerner . The fix looks good to me, but I would love a few others on the @grafana/dataviz-squad to take a look too make sure this doesn't adversely/unexpectedly touch anything and have unintended interactions elsewhere. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution! This appears to be working and it makes sense that the value field for a reduction would be the first field (i.e. index 0). I'm not sure if this has broader impact however and it would be good to get someone to chime in on that.
Going by file history maybe @drew08t or @ryantxu might know?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure of the implications of hard coding the value row index here, @leeoniya do you have any insights on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've narrowed the change and added more commentary. The change is now more minimal.
On some level, choosing valueRowIndex: 0
can be wrong. If you have more than one row in the data frame then the calc that was run may not be totally meaningful. Indeed this is referring to the entire data frame here when we talk about the ${__data}
macros and then scoped to the relevant row through this mechanism here.
The more minimal and correct thing I've now done to limit this change to apply only to data frames with a single row. Then there's no doubt that it's the right choice for the row index (it's the only reasonable choice :p).
d61e126
to
8f5353d
Compare
I think the failure on that CI step was some sort of infra misconfiguration or flake or something. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is reasonable, thanks for diving deeper into this - I think this solution is "good enough" for the time being 👍
@ajwerner we made some build changes recently so to get this merged you will need to merge this branch onto latest main
thanks! |
For panels like Stat, data links which referred to fields did not end up rendering because the rowIndex ended up being undefined. When the row index is undefined, the data macro expansion for fields does not trigger (see [0]). This change allows these links to work when the query returns exactly one row. This is not a complete fix for the problem in the general, but a TODO with more details on a complete solution were added around the change. 0: https://github.com/grafana/grafana/blob/878ba96a/public/app/features/templating/dataMacros.ts#L99-L101 Fixes grafana#60297
Head branch was pushed to by a user without write access
8f5353d
to
0545902
Compare
@nmarrs I rebased main |
What is this feature?
Fixes a bug whereby data links in Stat panels (and probably other "reduced" data panels) could not refer to the
${__data.fields}
macros available in other panels.For these panels, data links which referred to fields did not end up rendering because the rowIndex ended up being undefined. When the row index is undefined, the data macro expansion for fields does not trigger (see 0).
Why do we need this feature?
It's often very nice to link to data that you are not displaying. See the chatter in #60297.
Who is this feature for?
Grafana users who like data links.
Which issue(s) does this PR fix?:
Fixes #60297
Special notes for your reviewer:
Please check that: