This is an automated email from the ASF dual-hosted git repository.
miao pushed a commit to branch grafana_plugin
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/grafana_plugin by this push:
new 10e55666cd7 Fixed the issue where the Grafana plugin does not display
data when there is no time value
10e55666cd7 is described below
commit 10e55666cd73255891a6810036ba5b58b6cb32fb
Author: luke.miao <[email protected]>
AuthorDate: Tue Jul 30 10:22:18 2024 +0800
Fixed the issue where the Grafana plugin does not display data when there
is no time value
---
.../grafana-plugin/pkg/plugin/plugin.go | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/iotdb-connector/grafana-plugin/pkg/plugin/plugin.go
b/iotdb-connector/grafana-plugin/pkg/plugin/plugin.go
index eea05bf3885..6d9f9783a7a 100644
--- a/iotdb-connector/grafana-plugin/pkg/plugin/plugin.go
+++ b/iotdb-connector/grafana-plugin/pkg/plugin/plugin.go
@@ -291,20 +291,26 @@ func (d *IoTDBDataSource) query(cxt context.Context, pCtx
backend.PluginContext,
}
// create data frame response.
frame := data.NewFrame("response")
- times := nil
for i := 0; i < len(queryDataResp.Expressions); i++ {
if queryDataResp.Timestamps != nil &&
len(queryDataResp.Timestamps) > 0 {
times := make([]time.Time,
len(queryDataResp.Timestamps))
for c := 0; c < len(queryDataResp.Timestamps); c++ {
times[c] = time.Unix(0,
queryDataResp.Timestamps[c]*1000000)
}
- }
- if queryDataResp.Values != nil && len(queryDataResp.Values) > 0
{
- values := recoverType(queryDataResp.Values[i])
- frame.Fields = append(frame.Fields,
- data.NewField("time", nil, times),
- data.NewField(queryDataResp.Expressions[i],
nil, values),
- )
+ if queryDataResp.Values != nil &&
len(queryDataResp.Values) > 0 {
+ values := recoverType(queryDataResp.Values[i])
+ frame.Fields = append(frame.Fields,
+ data.NewField("time", nil, times),
+
data.NewField(queryDataResp.Expressions[i], nil, values),
+ )
+ }
+ } else {
+ if queryDataResp.Values != nil &&
len(queryDataResp.Values) > 0 {
+ values := recoverType(queryDataResp.Values[i])
+ frame.Fields = append(frame.Fields,
+
data.NewField(queryDataResp.Expressions[i], nil, values),
+ )
+ }
}
}