|
|
|
@ -78,7 +78,7 @@ export interface GetFieldDisplayValuesOptions { |
|
|
|
|
export const DEFAULT_FIELD_DISPLAY_VALUES_LIMIT = 25; |
|
|
|
|
|
|
|
|
|
export const getFieldDisplayValues = (options: GetFieldDisplayValuesOptions): FieldDisplay[] => { |
|
|
|
|
const { replaceVariables, reduceOptions, timeZone } = options; |
|
|
|
|
const { replaceVariables, reduceOptions, timeZone, theme } = options; |
|
|
|
|
const calcs = reduceOptions.calcs.length ? reduceOptions.calcs : [ReducerID.last]; |
|
|
|
|
|
|
|
|
|
const values: FieldDisplay[] = []; |
|
|
|
@ -152,6 +152,8 @@ export const getFieldDisplayValues = (options: GetFieldDisplayValuesOptions): Fi |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
field.state = setIndexForPaletteColor(field, values.length); |
|
|
|
|
|
|
|
|
|
const displayValue = display(field.values.get(j)); |
|
|
|
|
|
|
|
|
|
if (displayName !== '') { |
|
|
|
@ -163,6 +165,11 @@ export const getFieldDisplayValues = (options: GetFieldDisplayValuesOptions): Fi |
|
|
|
|
displayValue.title = getSmartDisplayNameForRow(dataFrame, field, j); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const overrideColor = lookupRowColorFromOverride(displayValue, options.fieldConfig); |
|
|
|
|
if (overrideColor) { |
|
|
|
|
displayValue.color = theme.visualization.getColorByName(overrideColor); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
values.push({ |
|
|
|
|
name: '', |
|
|
|
|
field: config, |
|
|
|
@ -269,6 +276,32 @@ function getSmartDisplayNameForRow(frame: DataFrame, field: Field, rowIndex: num |
|
|
|
|
return parts.join(' '); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Palette color modes use series index (field index) which does not work for when displaing rows |
|
|
|
|
* So updating seriesIndex here makes the palette color modes work in "All values" mode |
|
|
|
|
*/ |
|
|
|
|
function setIndexForPaletteColor(field: Field, currentLength: number) { |
|
|
|
|
return { |
|
|
|
|
...field.state, |
|
|
|
|
seriesIndex: currentLength, |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* This function makes overrides that set color work for row values |
|
|
|
|
*/ |
|
|
|
|
function lookupRowColorFromOverride(display: DisplayValue, fieldConfig: FieldConfigSource) { |
|
|
|
|
for (const override of fieldConfig.overrides) { |
|
|
|
|
if (override.matcher.id === 'byName' && override.matcher.options === display.title) { |
|
|
|
|
for (const prop of override.properties) { |
|
|
|
|
if (prop.id === 'color' && prop.value) { |
|
|
|
|
return prop.value.fixedColor; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export function hasLinks(field: Field): boolean { |
|
|
|
|
return field.config?.links?.length ? field.config.links.length > 0 : false; |
|
|
|
|
} |
|
|
|
|