NodeGraph: Show gradient fields in legend (#34078)

* Add gradient fields to legend

* Fix test

* Remove unnecessary mapping

* Add tests
This commit is contained in:
Andrej Ocenas
2021-05-18 16:30:27 +02:00
committed by GitHub
parent bbaa7a9b62
commit 2e7ccf0e42
14 changed files with 161 additions and 46 deletions

View File

@ -4,7 +4,6 @@ import {
Field,
FieldCache,
FieldType,
getFieldColorModeForField,
GrafanaTheme2,
MutableDataFrame,
NodeGraphDataFrameFieldNames,
@ -100,7 +99,7 @@ export function processNodes(
mainStat: nodeFields.mainStat,
secondaryStat: nodeFields.secondaryStat,
arcSections: nodeFields.arc,
color: nodeFields.color ? getColor(nodeFields.color, index, theme) : '',
color: nodeFields.color,
};
return acc;
}, {}) || {};
@ -271,14 +270,6 @@ function edgesFrame() {
});
}
function getColor(field: Field, index: number, theme: GrafanaTheme2): string {
if (!field.config.color) {
return field.values.get(index);
}
return getFieldColorModeForField(field).getCalculator(field, theme)(0, field.values.get(index));
}
export interface Bounds {
top: number;
right: number;