Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
1ffcb002
Commit
1ffcb002
authored
Oct 16, 2019
by
Kyle Brandt
Committed by
Ryan McKinley
Oct 16, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DataFrame: guess number field when on NaN (#19833)
parent
4d214f5a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
1 deletions
+4
-1
packages/grafana-data/src/dataframe/processDataFrame.test.ts
+3
-0
packages/grafana-data/src/dataframe/processDataFrame.ts
+1
-1
No files found.
packages/grafana-data/src/dataframe/processDataFrame.test.ts
View file @
1ffcb002
...
...
@@ -81,6 +81,7 @@ describe('toDataFrame', () => {
it
(
'Guess Colum Types from strings'
,
()
=>
{
expect
(
guessFieldTypeFromValue
(
'1'
)).
toBe
(
FieldType
.
number
);
expect
(
guessFieldTypeFromValue
(
'1.234'
)).
toBe
(
FieldType
.
number
);
expect
(
guessFieldTypeFromValue
(
'NaN'
)).
toBe
(
FieldType
.
number
);
expect
(
guessFieldTypeFromValue
(
'3.125e7'
)).
toBe
(
FieldType
.
number
);
expect
(
guessFieldTypeFromValue
(
'True'
)).
toBe
(
FieldType
.
boolean
);
expect
(
guessFieldTypeFromValue
(
'FALSE'
)).
toBe
(
FieldType
.
boolean
);
...
...
@@ -95,6 +96,7 @@ describe('toDataFrame', () => {
{
name
:
'B (strings)'
,
values
:
[
null
,
'Hello'
]
},
{
name
:
'C (nulls)'
,
values
:
[
null
,
null
]
},
{
name
:
'Time'
,
values
:
[
'2000'
,
1967
]
},
{
name
:
'D (number strings)'
,
values
:
[
'NaN'
,
null
,
1
]
},
],
});
const
norm
=
guessFieldTypes
(
series
);
...
...
@@ -102,6 +104,7 @@ describe('toDataFrame', () => {
expect
(
norm
.
fields
[
1
].
type
).
toBe
(
FieldType
.
string
);
expect
(
norm
.
fields
[
2
].
type
).
toBe
(
FieldType
.
other
);
expect
(
norm
.
fields
[
3
].
type
).
toBe
(
FieldType
.
time
);
// based on name
expect
(
norm
.
fields
[
4
].
type
).
toBe
(
FieldType
.
number
);
});
it
(
'converts JSON document data to series'
,
()
=>
{
...
...
packages/grafana-data/src/dataframe/processDataFrame.ts
View file @
1ffcb002
...
...
@@ -156,7 +156,7 @@ function convertJSONDocumentDataToDataFrame(timeSeries: TimeSeries): DataFrame {
// PapaParse Dynamic Typing regex:
// https://github.com/mholt/PapaParse/blob/master/papaparse.js#L998
const
NUMBER
=
/^
\s
*
-
?(\d
*
\.?\d
+|
\d
+
\.?\d
*
)(
e
[
-+
]?\d
+
)?
\s
*$/i
;
const
NUMBER
=
/^
\s
*
(
-
?(\d
*
\.?\d
+|
\d
+
\.?\d
*
)(
e
[
-+
]?\d
+
)?
|NAN
)
\s
*$/i
;
/**
* Given a value this will guess the best column type
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment