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
c629a58b
Commit
c629a58b
authored
Dec 07, 2017
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: removed graph height from legend decimal calc
parent
a7897b94
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
26 deletions
+13
-26
public/app/core/time_series2.ts
+2
-3
public/app/core/utils/ticks.ts
+2
-18
public/app/plugins/panel/graph/legend.ts
+9
-5
No files found.
public/app/core/time_series2.ts
View file @
c629a58b
...
...
@@ -21,14 +21,13 @@ function translateFillOption(fill) {
* Calculate decimals for legend and update values for each series.
* @param data series data
* @param panel
* @param height Graph height
*/
export
function
updateLegendValues
(
data
:
TimeSeries
[],
panel
,
height
)
{
export
function
updateLegendValues
(
data
:
TimeSeries
[],
panel
)
{
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
let
series
=
data
[
i
];
let
yaxes
=
panel
.
yaxes
;
let
axis
=
yaxes
[
series
.
yaxis
-
1
];
let
{
tickDecimals
,
scaledDecimals
}
=
getFlotTickDecimals
(
data
,
axis
,
height
);
let
{
tickDecimals
,
scaledDecimals
}
=
getFlotTickDecimals
(
data
,
axis
);
let
formater
=
kbn
.
valueFormats
[
panel
.
yaxes
[
series
.
yaxis
-
1
].
format
];
// decimal override
...
...
public/app/core/utils/ticks.ts
View file @
c629a58b
...
...
@@ -118,29 +118,13 @@ export function getFlotRange(panelMin, panelMax, datamin, datamax) {
}
/**
* Estimate number of ticks for Y axis.
* Implementation from Flot.
*/
export
function
getFlotNumberOfTicks
(
height
,
ticks
?)
{
let
noTicks
;
if
(
typeof
ticks
===
"number"
&&
ticks
>
0
)
{
noTicks
=
ticks
;
}
else
{
// heuristic based on the model a*sqrt(x) fitted to
// some data points that seemed reasonable
noTicks
=
0.3
*
Math
.
sqrt
(
height
);
}
return
noTicks
;
}
/**
* Calculate tick decimals.
* Implementation from Flot.
*/
export
function
getFlotTickDecimals
(
data
,
axis
,
height
)
{
export
function
getFlotTickDecimals
(
data
,
axis
)
{
let
{
datamin
,
datamax
}
=
getDataMinMax
(
data
);
let
{
min
,
max
}
=
getFlotRange
(
axis
.
min
,
axis
.
max
,
datamin
,
datamax
);
let
noTicks
=
getFlotNumberOfTicks
(
height
)
;
let
noTicks
=
3
;
let
tickDecimals
,
maxDec
;
let
delta
=
(
max
-
min
)
/
noTicks
;
let
dec
=
-
Math
.
floor
(
Math
.
log
(
delta
)
/
Math
.
LN10
);
...
...
public/app/plugins/panel/graph/legend.ts
View file @
c629a58b
...
...
@@ -19,6 +19,10 @@ module.directive('graphLegend', function(popoverSrv, $timeout) {
var
i
;
var
legendScrollbar
;
scope
.
$on
(
"$destroy"
,
function
()
{
legendScrollbar
.
destroy
();
});
ctrl
.
events
.
on
(
'render-legend'
,
()
=>
{
data
=
ctrl
.
seriesList
;
if
(
data
)
{
...
...
@@ -27,8 +31,8 @@ module.directive('graphLegend', function(popoverSrv, $timeout) {
ctrl
.
events
.
emit
(
'legend-rendering-complete'
);
});
function
updateLegendDecimals
(
graphHeight
)
{
updateLegendValues
(
data
,
panel
,
graphHeight
);
function
updateLegendDecimals
()
{
updateLegendValues
(
data
,
panel
);
}
function
getSeriesIndexForElement
(
el
)
{
...
...
@@ -157,11 +161,10 @@ module.directive('graphLegend', function(popoverSrv, $timeout) {
// render first time for getting proper legend height
if
(
!
panel
.
legend
.
rightSide
)
{
renderLegendElement
(
tableHeaderElem
);
let
graphHeight
=
ctrl
.
height
-
$container
.
height
()
-
23
;
updateLegendDecimals
(
graphHeight
);
updateLegendDecimals
();
$container
.
empty
();
}
else
{
updateLegendDecimals
(
ctrl
.
height
);
updateLegendDecimals
();
}
renderLegendElement
(
tableHeaderElem
);
...
...
@@ -227,6 +230,7 @@ module.directive('graphLegend', function(popoverSrv, $timeout) {
var
maxLegendHeight
=
ctrl
.
height
/
2
;
$container
.
css
(
"max-height"
,
maxLegendHeight
-
6
);
$container
.
append
(
seriesElements
);
if
(
!
legendScrollbar
)
{
legendScrollbar
=
new
PerfectScrollbar
(
$container
[
0
]);
}
...
...
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