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
5b1f0bb0
Commit
5b1f0bb0
authored
Apr 10, 2019
by
Dominik Prokop
Committed by
Torkel Ödegaard
Apr 10, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PanelData: Rename ColumnStats type to FieldStats (#16494)
parent
5bc936d2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
+10
-10
packages/grafana-ui/src/utils/statsCalculator.ts
+10
-10
No files found.
packages/grafana-ui/src/utils/statsCalculator.ts
View file @
5b1f0bb0
...
...
@@ -24,12 +24,12 @@ export enum StatID {
allIsNull
=
'allIsNull'
,
}
export
interface
Column
Stats
{
export
interface
Field
Stats
{
[
key
:
string
]:
any
;
}
// Internal function
type
StatCalculator
=
(
data
:
SeriesData
,
fieldIndex
:
number
,
ignoreNulls
:
boolean
,
nullAsZero
:
boolean
)
=>
Column
Stats
;
type
StatCalculator
=
(
data
:
SeriesData
,
fieldIndex
:
number
,
ignoreNulls
:
boolean
,
nullAsZero
:
boolean
)
=>
Field
Stats
;
export
interface
StatCalculatorInfo
{
id
:
string
;
...
...
@@ -73,7 +73,7 @@ export interface CalculateStatsOptions {
/**
* @returns an object with a key for each selected stat
*/
export
function
calculateStats
(
options
:
CalculateStatsOptions
):
Column
Stats
{
export
function
calculateStats
(
options
:
CalculateStatsOptions
):
Field
Stats
{
const
{
series
,
fieldIndex
,
stats
,
nullValueMode
}
=
options
;
if
(
!
stats
||
stats
.
length
<
1
)
{
...
...
@@ -85,7 +85,7 @@ export function calculateStats(options: CalculateStatsOptions): ColumnStats {
// Return early for empty series
// This lets the concrete implementations assume at least one row
if
(
!
series
.
rows
||
series
.
rows
.
length
<
1
)
{
const
stats
=
{}
as
Column
Stats
;
const
stats
=
{}
as
Field
Stats
;
for
(
const
stat
of
queue
)
{
stats
[
stat
.
id
]
=
stat
.
emptyInputResult
!==
null
?
stat
.
emptyInputResult
:
null
;
}
...
...
@@ -227,7 +227,7 @@ function standardStatsStat(
fieldIndex
:
number
,
ignoreNulls
:
boolean
,
nullAsZero
:
boolean
):
Column
Stats
{
):
Field
Stats
{
const
stats
=
{
sum
:
0
,
max
:
-
Number
.
MAX_VALUE
,
...
...
@@ -247,7 +247,7 @@ function standardStatsStat(
// Just used for calcutations -- not exposed as a stat
previousDeltaUp
:
true
,
}
as
Column
Stats
;
}
as
Field
Stats
;
for
(
let
i
=
0
;
i
<
data
.
rows
.
length
;
i
++
)
{
let
currentValue
=
data
.
rows
[
i
][
fieldIndex
];
...
...
@@ -345,11 +345,11 @@ function standardStatsStat(
return
stats
;
}
function
calculateFirst
(
data
:
SeriesData
,
fieldIndex
:
number
,
ignoreNulls
:
boolean
,
nullAsZero
:
boolean
):
Column
Stats
{
function
calculateFirst
(
data
:
SeriesData
,
fieldIndex
:
number
,
ignoreNulls
:
boolean
,
nullAsZero
:
boolean
):
Field
Stats
{
return
{
first
:
data
.
rows
[
0
][
fieldIndex
]
};
}
function
calculateLast
(
data
:
SeriesData
,
fieldIndex
:
number
,
ignoreNulls
:
boolean
,
nullAsZero
:
boolean
):
Column
Stats
{
function
calculateLast
(
data
:
SeriesData
,
fieldIndex
:
number
,
ignoreNulls
:
boolean
,
nullAsZero
:
boolean
):
Field
Stats
{
return
{
last
:
data
.
rows
[
data
.
rows
.
length
-
1
][
fieldIndex
]
};
}
...
...
@@ -358,7 +358,7 @@ function calculateChangeCount(
fieldIndex
:
number
,
ignoreNulls
:
boolean
,
nullAsZero
:
boolean
):
Column
Stats
{
):
Field
Stats
{
let
count
=
0
;
let
first
=
true
;
let
last
:
any
=
null
;
...
...
@@ -387,7 +387,7 @@ function calculateDistinctCount(
fieldIndex
:
number
,
ignoreNulls
:
boolean
,
nullAsZero
:
boolean
):
Column
Stats
{
):
Field
Stats
{
const
distinct
=
new
Set
<
any
>
();
for
(
let
i
=
0
;
i
<
data
.
rows
.
length
;
i
++
)
{
let
currentValue
=
data
.
rows
[
i
][
fieldIndex
];
...
...
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