Skip to content

Commit 2193e14

Browse files
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
1 parent d5a37e8 commit 2193e14

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

connectors/grafana-plugin/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "iotdb",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "Apache IoTDB",
55
"scripts": {
66
"build": "grafana-toolkit plugin:build",

connectors/grafana-plugin/pkg/plugin/plugin.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"errors"
2525
"fmt"
2626
"io"
27+
"math"
2728
"net/http"
2829
"strconv"
2930
"strings"
@@ -325,7 +326,7 @@ func recoverType(m []interface{}) interface{} {
325326
tmp := make([]float64, len(m))
326327
for i := range m {
327328
if m[i] == nil {
328-
tmp[i] = 0
329+
tmp[i] = math.NaN()
329330
} else {
330331
tmp[i] = m[i].(float64)
331332
}
@@ -340,7 +341,9 @@ func recoverType(m []interface{}) interface{} {
340341
case bool:
341342
tmp := make([]float64, len(m))
342343
for i := range m {
343-
if m[i].(bool) {
344+
if m[i] == nil {
345+
tmp[i] = math.NaN()
346+
} else if m[i].(bool) {
344347
tmp[i] = 1
345348
} else {
346349
tmp[i] = 0
@@ -351,7 +354,7 @@ func recoverType(m []interface{}) interface{} {
351354
tmp := make([]float64, len(m))
352355
for i := range m {
353356
if m[i] == nil {
354-
tmp[i] = 0
357+
tmp[i] = math.NaN()
355358
} else {
356359
tmp[i] = m[i].(float64)
357360
}

0 commit comments

Comments
 (0)