mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Stat: Fix data links that refer to fields (#80693)
This commit is contained in:
parent
11997a6d35
commit
c9bdf69a46
@ -204,6 +204,25 @@ export const getFieldDisplayValues = (options: GetFieldDisplayValuesOptions): Fi
|
||||
}
|
||||
}
|
||||
|
||||
// If there is only one row in the data frame, then set the
|
||||
// valueRowIndex to that one row. This allows the data macros in
|
||||
// things like links to access other fields from the data frame.
|
||||
//
|
||||
// If there were more rows, it still may be sane to set the row
|
||||
// index, but it may be confusing; the calculation may have
|
||||
// selected a value from a different row or it may have aggregated
|
||||
// the values from multiple rows, so to make just the first row
|
||||
// available would be arbitrary. For now, the users will have to
|
||||
// ensure that the data frame has just one row if they want data
|
||||
// link referencing other fields to work.
|
||||
//
|
||||
// TODO: A more complete solution here would be to allow the
|
||||
// calculation to report a relevant row and use that value. For
|
||||
// example, a common calculation is 'lastNotNull'. It'd be nifty to
|
||||
// know which row the display value corresponds to in that case if
|
||||
// there were potentially many
|
||||
const valueRowIndex = dataFrame.length === 1 ? 0 : undefined;
|
||||
|
||||
values.push({
|
||||
name: calc,
|
||||
field: config,
|
||||
@ -215,6 +234,7 @@ export const getFieldDisplayValues = (options: GetFieldDisplayValuesOptions): Fi
|
||||
? () =>
|
||||
fieldLinksSupplier({
|
||||
calculatedValue: displayValue,
|
||||
valueRowIndex,
|
||||
})
|
||||
: () => [],
|
||||
hasLinks: hasLinks(field),
|
||||
|
Loading…
Reference in New Issue
Block a user