Skip to content

Commit cdb4484

Browse files
fix: Fixes legends on hisRead and hisReadFilter
1 parent 0305851 commit cdb4484

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

pkg/plugin/datasource.go

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,17 @@ func (datasource *Datasource) query(ctx context.Context, pCtx backend.PluginCont
152152
log.DefaultLogger.Error(err.Error())
153153
return backend.ErrDataResponse(backend.StatusBadRequest, fmt.Sprintf("HisRead failure: %v", err.Error()))
154154
}
155-
return responseFromGrids([]haystack.Grid{hisRead})
155+
response := responseFromGrids([]haystack.Grid{hisRead})
156+
// Make the display name on the "val" field the name of the point.
157+
for _, frame := range response.Frames {
158+
for _, field := range frame.Fields {
159+
if field.Name == "val" {
160+
field.Config.DisplayName = frame.Name
161+
}
162+
}
163+
}
164+
return response
165+
156166
case "hisReadFilter":
157167
points, readErr := datasource.read(model.HisReadFilter, variables)
158168
if readErr != nil {
@@ -179,7 +189,16 @@ func (datasource *Datasource) query(ctx context.Context, pCtx backend.PluginCont
179189
}
180190
grids = append(grids, hisRead)
181191
}
182-
return responseFromGrids(grids)
192+
response := responseFromGrids(grids)
193+
// Make the display name on the "val" fields the names of the points.
194+
for _, frame := range response.Frames {
195+
for _, field := range frame.Fields {
196+
if field.Name == "val" {
197+
field.Config.DisplayName = frame.Name
198+
}
199+
}
200+
}
201+
return response
183202
case "read":
184203
read, err := datasource.read(model.Read, variables)
185204
if err != nil {

0 commit comments

Comments
 (0)