Skip to content

Commit 3294411

Browse files
timoaocenas
andauthored
NodeGraph: Fix configuring arc colors with mixed case field names (#84609)
* NodeGraphPanel: Fix case comparison for arc field colors When a field has mixed case in the data frame, the options editor offers it with mixed case as well, so the options will have the field with mixed case as well, making the comparison in utils.ts applyOptiosToFrames fail, leaving the arcs uncolored. This version of the commit allows mismatched cases between field in dataframe and options panel in case users were depending on this behavior in their dashboards. * Update comment --------- Co-authored-by: Andrej Ocenas <[email protected]>
1 parent c7573bb commit 3294411

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

public/app/plugins/panel/nodeGraph/utils.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ describe('processNodes', () => {
170170
{ name: 'mainStat', type: FieldType.string },
171171
{ name: 'secondaryStat', type: FieldType.string },
172172
{ name: 'arc__primary', type: FieldType.string },
173-
{ name: 'arc__secondary', type: FieldType.string },
173+
{ name: 'arc__Secondary', type: FieldType.string },
174174
{ name: 'arc__tertiary', type: FieldType.string },
175175
],
176176
}),
@@ -192,7 +192,7 @@ describe('processNodes', () => {
192192
secondaryStatUnit: 'ms/r',
193193
arcs: [
194194
{ field: 'arc__primary', color: 'red' },
195-
{ field: 'arc__secondary', color: 'yellow' },
195+
{ field: 'arc__Secondary', color: 'yellow' },
196196
{ field: 'arc__tertiary', color: '#dd40ec' },
197197
],
198198
},
@@ -212,7 +212,7 @@ describe('processNodes', () => {
212212
expect(nodesFrame?.fields.find((f) => f.name === 'arc__primary')?.config).toEqual({
213213
color: { mode: 'fixed', fixedColor: 'red' },
214214
});
215-
expect(nodesFrame?.fields.find((f) => f.name === 'arc__secondary')?.config).toEqual({
215+
expect(nodesFrame?.fields.find((f) => f.name === 'arc__Secondary')?.config).toEqual({
216216
color: { mode: 'fixed', fixedColor: 'yellow' },
217217
});
218218
expect(nodesFrame?.fields.find((f) => f.name === 'arc__tertiary')?.config).toEqual({

public/app/plugins/panel/nodeGraph/utils.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,8 @@ export const applyOptionsToFrames = (frames: DataFrame[], options: NodeGraphOpti
599599
}
600600
if (options?.nodes?.arcs?.length) {
601601
for (const arc of options.nodes.arcs) {
602-
const field = frame.fields.find((field) => field.name.toLowerCase() === arc.field);
602+
// As the arc__ field suffixes can be custom we compare them case insensitively to be safe.
603+
const field = frame.fields.find((field) => field.name.toLowerCase() === arc.field?.toLowerCase());
603604
if (field && arc.color) {
604605
field.config = { ...field.config, color: { fixedColor: arc.color, mode: FieldColorModeId.Fixed } };
605606
}

0 commit comments

Comments
 (0)