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
eed0d9c8
Commit
eed0d9c8
authored
Jun 08, 2016
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(graph performance): graph performance tweaks, refactoring #5297
parent
bf82fdb6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
26 deletions
+17
-26
public/app/core/profiler.ts
+4
-3
public/app/plugins/panel/graph/graph.js
+13
-23
No files found.
public/app/core/profiler.ts
View file @
eed0d9c8
...
@@ -36,7 +36,9 @@ export class Profiler {
...
@@ -36,7 +36,9 @@ export class Profiler {
}
}
refresh
()
{
refresh
()
{
if
(
this
.
panels
.
length
>
0
)
{
this
.
panels
=
[];
setTimeout
(()
=>
{
var
totalRender
=
0
;
var
totalRender
=
0
;
var
totalQuery
=
0
;
var
totalQuery
=
0
;
...
@@ -49,8 +51,7 @@ export class Profiler {
...
@@ -49,8 +51,7 @@ export class Profiler {
console
.
log
(
'total query: '
+
totalQuery
);
console
.
log
(
'total query: '
+
totalQuery
);
console
.
log
(
'total render: '
+
totalRender
);
console
.
log
(
'total render: '
+
totalRender
);
console
.
log
(
'avg render: '
+
totalRender
/
this
.
panels
.
length
);
console
.
log
(
'avg render: '
+
totalRender
/
this
.
panels
.
length
);
}
},
5000
);
this
.
$rootScope
.
panels
=
[];
}
}
dashboardFetched
()
{
dashboardFetched
()
{
...
...
public/app/plugins/panel/graph/graph.js
View file @
eed0d9c8
...
@@ -18,6 +18,8 @@ function (angular, $, moment, _, kbn, GraphTooltip) {
...
@@ -18,6 +18,8 @@ function (angular, $, moment, _, kbn, GraphTooltip) {
'use strict'
;
'use strict'
;
var
module
=
angular
.
module
(
'grafana.directives'
);
var
module
=
angular
.
module
(
'grafana.directives'
);
var
labelWidthCache
=
{};
var
panelWidthCache
=
{};
module
.
directive
(
'grafanaGraph'
,
function
(
$rootScope
,
timeSrv
)
{
module
.
directive
(
'grafanaGraph'
,
function
(
$rootScope
,
timeSrv
)
{
return
{
return
{
...
@@ -110,20 +112,13 @@ function (angular, $, moment, _, kbn, GraphTooltip) {
...
@@ -110,20 +112,13 @@ function (angular, $, moment, _, kbn, GraphTooltip) {
}
}
}
}
function
getLabelWidth
(
type
,
text
,
elem
)
{
function
getLabelWidth
(
text
,
elem
)
{
var
labelWidth
=
0
;
var
labelWidth
=
labelWidthCache
[
text
];
if
(
!
rootScope
.
labelWidthCache
)
{
rootScope
.
labelWidthCache
=
{};
if
(
!
labelWidth
)
{
}
labelWidth
=
labelWidthCache
[
text
]
=
elem
.
width
();
if
(
!
rootScope
.
labelWidthCache
[
type
])
{
rootScope
.
labelWidthCache
[
type
]
=
{};
}
if
(
rootScope
.
labelWidthCache
[
type
][
text
])
{
labelWidth
=
rootScope
.
labelWidthCache
[
type
][
text
];
}
else
{
labelWidth
=
elem
.
width
();
rootScope
.
labelWidthCache
[
type
][
text
]
=
labelWidth
;
}
}
return
labelWidth
;
return
labelWidth
;
}
}
...
@@ -155,7 +150,7 @@ function (angular, $, moment, _, kbn, GraphTooltip) {
...
@@ -155,7 +150,7 @@ function (angular, $, moment, _, kbn, GraphTooltip) {
.
text
(
panel
.
yaxes
[
0
].
label
)
.
text
(
panel
.
yaxes
[
0
].
label
)
.
appendTo
(
elem
);
.
appendTo
(
elem
);
yaxisLabel
[
0
].
style
.
marginTop
=
(
getLabelWidth
(
'left'
,
panel
.
yaxes
[
0
].
label
,
yaxisLabel
)
/
2
)
+
'px'
;
yaxisLabel
[
0
].
style
.
marginTop
=
(
getLabelWidth
(
panel
.
yaxes
[
0
].
label
,
yaxisLabel
)
/
2
)
+
'px'
;
}
}
// add right axis labels
// add right axis labels
...
@@ -164,7 +159,7 @@ function (angular, $, moment, _, kbn, GraphTooltip) {
...
@@ -164,7 +159,7 @@ function (angular, $, moment, _, kbn, GraphTooltip) {
.
text
(
panel
.
yaxes
[
1
].
label
)
.
text
(
panel
.
yaxes
[
1
].
label
)
.
appendTo
(
elem
);
.
appendTo
(
elem
);
rightLabel
[
0
].
style
.
marginTop
=
(
getLabelWidth
(
'right'
,
panel
.
yaxes
[
1
].
label
,
rightLabel
)
/
2
)
+
'px'
;
rightLabel
[
0
].
style
.
marginTop
=
(
getLabelWidth
(
panel
.
yaxes
[
1
].
label
,
rightLabel
)
/
2
)
+
'px'
;
}
}
}
}
...
@@ -177,14 +172,9 @@ function (angular, $, moment, _, kbn, GraphTooltip) {
...
@@ -177,14 +172,9 @@ function (angular, $, moment, _, kbn, GraphTooltip) {
// Function for rendering panel
// Function for rendering panel
function
render_panel
()
{
function
render_panel
()
{
if
(
!
rootScope
.
panelWidthCache
)
{
panelWidth
=
panelWidthCache
[
panel
.
span
];
rootScope
.
panelWidthCache
=
{};
if
(
!
panelWidth
)
{
}
panelWidth
=
panelWidthCache
[
panel
.
span
]
=
elem
.
width
();
if
(
rootScope
.
panelWidthCache
[
panel
.
span
])
{
panelWidth
=
rootScope
.
panelWidthCache
[
panel
.
span
];
}
else
{
panelWidth
=
elem
.
width
();
rootScope
.
panelWidthCache
[
panel
.
span
]
=
panelWidth
;
}
}
if
(
shouldAbortRender
())
{
if
(
shouldAbortRender
())
{
...
...
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