Skip to content
This repository was archived by the owner on Aug 4, 2025. It is now read-only.

Commit 58d0171

Browse files
committed
fix not displaying legends for the colors
1 parent 99e8aa3 commit 58d0171

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

example/api/python/run.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ def fetch_graph_fields():
1212
{"field_name": "mainStat", "type": "string"},
1313
{"field_name": "secondaryStat", "type": "number"},
1414
{"field_name": "arc__failed",
15-
"type": "number", "color": "red"},
15+
"type": "number", "color": "red", "displayName": "Failed"},
1616
{"field_name": "arc__passed",
17-
"type": "number", "color": "green"},
17+
"type": "number", "color": "green", "displayName": "Passed"},
1818
{"field_name": "detail__role",
1919
"type": "string", "displayName": "Role"}]
2020
edges_fields = [

src/datasource.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export class DataSource extends DataSourceApi<MyQuery, MyDataSourceOptions> {
4343
interface FrameFieldType {
4444
name: string;
4545
type: any;
46-
config?: any;
46+
config: Record<string, any>;
4747
}
4848
// This function gets the fields of the api and transforms them to what grafana dataframe prefers
4949
function fieldAssignator(FieldsResponse: any): FrameFieldType[] {
@@ -52,14 +52,14 @@ export class DataSource extends DataSourceApi<MyQuery, MyDataSourceOptions> {
5252
// fieldType can be either number of string
5353
var fieldType = field['type'] === 'number' ? FieldType.number : FieldType.string;
5454
// add 'name' and 'type' items to the output object
55-
var outputField: FrameFieldType = { name: field['field_name'], type: fieldType };
55+
var outputField: FrameFieldType = { name: field['field_name'], type: fieldType, config: {} };
5656
// add color for 'arc__*' items(only apperas for the nodes)
5757
if ('color' in field) {
58-
outputField.config = { color: { fixedColor: field['color'], mode: FieldColorModeId.Fixed } };
58+
outputField.config.color = { fixedColor: field['color'], mode: FieldColorModeId.Fixed };
5959
}
6060
// add disPlayName for 'detail__*' items
6161
if ('displayName' in field) {
62-
outputField.config = { displayName: field['displayName'] };
62+
outputField.config.displayName = field['displayName'];
6363
}
6464
outputFields.push(outputField);
6565
});

0 commit comments

Comments
 (0)