This is an automated email from the ASF dual-hosted git repository.
critas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb-extras.git
The following commit(s) were added to refs/heads/master by this push:
new 2193e14 Fixed the issue of displaying 0 when the number is null (#32)
2193e14 is described below
commit 2193e14bad128d0ffd24344f83205f22038a0747
Author: CloudWise-Lukemiao <[email protected]>
AuthorDate: Tue Dec 10 18:19:08 2024 +0800
Fixed the issue of displaying 0 when the number is null (#32)
* Fixed the issue of displaying 0 when the number is null
* Fixed the issue of displaying 0 when the number is null
---
connectors/grafana-plugin/package.json | 2 +-
connectors/grafana-plugin/pkg/plugin/plugin.go | 9 ++++++---
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/connectors/grafana-plugin/package.json
b/connectors/grafana-plugin/package.json
index 675cd1e..246dc6a 100644
--- a/connectors/grafana-plugin/package.json
+++ b/connectors/grafana-plugin/package.json
@@ -1,6 +1,6 @@
{
"name": "iotdb",
- "version": "1.0.0",
+ "version": "1.0.1",
"description": "Apache IoTDB",
"scripts": {
"build": "grafana-toolkit plugin:build",
diff --git a/connectors/grafana-plugin/pkg/plugin/plugin.go
b/connectors/grafana-plugin/pkg/plugin/plugin.go
index 49f4a25..e0dba02 100644
--- a/connectors/grafana-plugin/pkg/plugin/plugin.go
+++ b/connectors/grafana-plugin/pkg/plugin/plugin.go
@@ -24,6 +24,7 @@ import (
"errors"
"fmt"
"io"
+ "math"
"net/http"
"strconv"
"strings"
@@ -325,7 +326,7 @@ func recoverType(m []interface{}) interface{} {
tmp := make([]float64, len(m))
for i := range m {
if m[i] == nil {
- tmp[i] = 0
+ tmp[i] = math.NaN()
} else {
tmp[i] = m[i].(float64)
}
@@ -340,7 +341,9 @@ func recoverType(m []interface{}) interface{} {
case bool:
tmp := make([]float64, len(m))
for i := range m {
- if m[i].(bool) {
+ if m[i] == nil {
+ tmp[i] = math.NaN()
+ } else if m[i].(bool) {
tmp[i] = 1
} else {
tmp[i] = 0
@@ -351,7 +354,7 @@ func recoverType(m []interface{}) interface{} {
tmp := make([]float64, len(m))
for i := range m {
if m[i] == nil {
- tmp[i] = 0
+ tmp[i] = math.NaN()
} else {
tmp[i] = m[i].(float64)
}