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
9ddfeaa9
Commit
9ddfeaa9
authored
Mar 30, 2017
by
Alexander Zobnin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
heatmap: initial ES histogram support
parent
3170f0d8
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
4 deletions
+58
-4
public/app/plugins/panel/heatmap/axes_editor.ts
+6
-0
public/app/plugins/panel/heatmap/heatmap_ctrl.ts
+42
-4
public/app/plugins/panel/heatmap/partials/axes_editor.html
+10
-0
No files found.
public/app/plugins/panel/heatmap/axes_editor.ts
View file @
9ddfeaa9
...
...
@@ -7,6 +7,7 @@ export class AxesEditorCtrl {
panelCtrl
:
any
;
unitFormats
:
any
;
logScales
:
any
;
dataFormats
:
any
;
/** @ngInject */
constructor
(
$scope
)
{
...
...
@@ -23,6 +24,11 @@ export class AxesEditorCtrl {
'log (base 32)'
:
32
,
'log (base 1024)'
:
1024
};
this
.
dataFormats
=
{
'Timeseries'
:
'timeseries'
,
'ES histogram'
:
'es_histogram'
};
}
setUnitFormat
(
subItem
)
{
...
...
public/app/plugins/panel/heatmap/heatmap_ctrl.ts
View file @
9ddfeaa9
...
...
@@ -7,7 +7,7 @@ import TimeSeries from 'app/core/time_series';
import
{
axesEditor
}
from
'./axes_editor'
;
import
{
heatmapDisplayEditor
}
from
'./display_editor'
;
import
rendering
from
'./rendering'
;
import
{
convertToHeatM
ap
,
getMinLog
}
from
'./heatmap_data_converter'
;
import
{
convertToHeatMap
,
elasticHistogramToHeatm
ap
,
getMinLog
}
from
'./heatmap_data_converter'
;
let
X_BUCKET_NUMBER_DEFAULT
=
30
;
let
Y_BUCKET_NUMBER_DEFAULT
=
10
;
...
...
@@ -27,6 +27,7 @@ let panelDefaults = {
colorScheme
:
'interpolateSpectral'
,
fillBackground
:
false
},
dataFormat
:
'timeseries'
,
xBucketSize
:
null
,
xBucketNumber
:
null
,
yBucketSize
:
null
,
...
...
@@ -137,7 +138,7 @@ export class HeatmapCtrl extends MetricsPanelCtrl {
onRender
()
{
if
(
!
this
.
range
)
{
return
;
}
let
xBucketSize
,
yBucketSize
;
let
xBucketSize
,
yBucketSize
,
heatmapStats
,
bucketsData
;
let
logBase
=
this
.
panel
.
yAxis
.
logBase
;
let
xBucketNumber
=
this
.
panel
.
xBucketNumber
||
X_BUCKET_NUMBER_DEFAULT
;
let
xBucketSizeByNumber
=
Math
.
floor
((
this
.
range
.
to
-
this
.
range
.
from
)
/
xBucketNumber
);
...
...
@@ -152,8 +153,10 @@ export class HeatmapCtrl extends MetricsPanelCtrl {
xBucketSize
=
Number
(
this
.
panel
.
xBucketSize
);
}
if
(
this
.
panel
.
dataFormat
===
'es_histogram'
)
{
heatmapStats
=
this
.
parseHistogramSeries
(
this
.
series
);
// Calculate Y bucket size
let
heatmapStats
=
this
.
parseSeries
(
this
.
series
);
let
yBucketNumber
=
this
.
panel
.
yBucketNumber
||
Y_BUCKET_NUMBER_DEFAULT
;
if
(
logBase
!==
1
)
{
yBucketSize
=
this
.
panel
.
yAxis
.
splitFactor
;
...
...
@@ -170,7 +173,29 @@ export class HeatmapCtrl extends MetricsPanelCtrl {
yBucketSize
=
this
.
panel
.
yBucketSize
||
yBucketSize
;
}
let
bucketsData
=
convertToHeatMap
(
this
.
series
,
yBucketSize
,
xBucketSize
,
logBase
);
bucketsData
=
elasticHistogramToHeatmap
(
this
.
series
);
}
else
{
// Calculate Y bucket size
heatmapStats
=
this
.
parseSeries
(
this
.
series
);
let
yBucketNumber
=
this
.
panel
.
yBucketNumber
||
Y_BUCKET_NUMBER_DEFAULT
;
if
(
logBase
!==
1
)
{
yBucketSize
=
this
.
panel
.
yAxis
.
splitFactor
;
}
else
{
if
(
heatmapStats
.
max
===
heatmapStats
.
min
)
{
if
(
heatmapStats
.
max
)
{
yBucketSize
=
heatmapStats
.
max
/
Y_BUCKET_NUMBER_DEFAULT
;
}
else
{
yBucketSize
=
1
;
}
}
else
{
yBucketSize
=
(
heatmapStats
.
max
-
heatmapStats
.
min
)
/
yBucketNumber
;
}
yBucketSize
=
this
.
panel
.
yBucketSize
||
yBucketSize
;
}
bucketsData
=
convertToHeatMap
(
this
.
series
,
yBucketSize
,
xBucketSize
,
logBase
);
}
// Set default Y range if no data
if
(
!
heatmapStats
.
min
&&
!
heatmapStats
.
max
)
{
...
...
@@ -252,6 +277,19 @@ export class HeatmapCtrl extends MetricsPanelCtrl {
};
}
parseHistogramSeries
(
series
)
{
let
bounds
=
_
.
map
(
series
,
s
=>
Number
(
s
.
alias
));
let
min
=
_
.
min
(
bounds
);
let
minLog
=
_
.
min
(
bounds
);
let
max
=
_
.
max
(
bounds
);
return
{
max
:
max
,
min
:
min
,
minLog
:
minLog
};
}
link
(
scope
,
elem
,
attrs
,
ctrl
)
{
rendering
(
scope
,
elem
,
attrs
,
ctrl
);
}
...
...
public/app/plugins/panel/heatmap/partials/axes_editor.html
View file @
9ddfeaa9
...
...
@@ -82,4 +82,14 @@
ng-model=
"ctrl.panel.xBucketSize"
ng-change=
"ctrl.refresh()"
ng-model-onblur
>
</div>
</div>
<div
class=
"section gf-form-group"
>
<h5
class=
"section-heading"
>
Data format
</h5>
<div
class=
"gf-form"
>
<label
class=
"gf-form-label width-5"
>
Format
</label>
<div
class=
"gf-form-select-wrapper max-width-15"
>
<select
class=
"gf-form-input"
ng-model=
"ctrl.panel.dataFormat"
ng-options=
"v as k for (k, v) in editor.dataFormats"
ng-change=
"ctrl.render()"
></select>
</div>
</div>
</div>
</div>
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