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
1976e185
Unverified
Commit
1976e185
authored
Nov 21, 2018
by
Torkel Ödegaard
Committed by
GitHub
Nov 21, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14145 from grafana/fix-legend-show-false
fixed issue with new legend not checking if panel.legend.show
parents
4bd8b2c1
0731b863
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
15 deletions
+13
-15
public/app/plugins/panel/graph/graph.ts
+12
-14
public/app/plugins/panel/graph/specs/graph.test.ts
+1
-1
No files found.
public/app/plugins/panel/graph/graph.ts
View file @
1976e185
...
@@ -58,15 +58,7 @@ class GraphElement {
...
@@ -58,15 +58,7 @@ class GraphElement {
// panel events
// panel events
this
.
ctrl
.
events
.
on
(
'panel-teardown'
,
this
.
onPanelTeardown
.
bind
(
this
));
this
.
ctrl
.
events
.
on
(
'panel-teardown'
,
this
.
onPanelTeardown
.
bind
(
this
));
/**
* Split graph rendering into two parts.
* First, calculate series stats in buildFlotPairs() function. Then legend rendering started
* (see ctrl.events.on('render') in legend.ts).
* When legend is rendered it emits 'legend-rendering-complete' and graph rendered.
*/
this
.
ctrl
.
events
.
on
(
'render'
,
this
.
onRender
.
bind
(
this
));
this
.
ctrl
.
events
.
on
(
'render'
,
this
.
onRender
.
bind
(
this
));
this
.
ctrl
.
events
.
on
(
'legend-rendering-complete'
,
this
.
onLegendRenderingComplete
.
bind
(
this
));
// global events
// global events
appEvents
.
on
(
'graph-hover'
,
this
.
onGraphHover
.
bind
(
this
),
scope
);
appEvents
.
on
(
'graph-hover'
,
this
.
onGraphHover
.
bind
(
this
),
scope
);
...
@@ -85,11 +77,20 @@ class GraphElement {
...
@@ -85,11 +77,20 @@ class GraphElement {
if
(
!
this
.
data
)
{
if
(
!
this
.
data
)
{
return
;
return
;
}
}
this
.
annotations
=
this
.
ctrl
.
annotations
||
[];
this
.
annotations
=
this
.
ctrl
.
annotations
||
[];
this
.
buildFlotPairs
(
this
.
data
);
this
.
buildFlotPairs
(
this
.
data
);
const
graphHeight
=
this
.
elem
.
height
();
const
graphHeight
=
this
.
elem
.
height
();
updateLegendValues
(
this
.
data
,
this
.
panel
,
graphHeight
);
updateLegendValues
(
this
.
data
,
this
.
panel
,
graphHeight
);
if
(
!
this
.
panel
.
legend
.
show
)
{
if
(
this
.
legendElem
.
hasChildNodes
())
{
ReactDOM
.
unmountComponentAtNode
(
this
.
legendElem
);
}
this
.
renderPanel
();
return
;
}
const
{
values
,
min
,
max
,
avg
,
current
,
total
}
=
this
.
panel
.
legend
;
const
{
values
,
min
,
max
,
avg
,
current
,
total
}
=
this
.
panel
.
legend
;
const
{
alignAsTable
,
rightSide
,
sideWidth
,
sort
,
sortDesc
,
hideEmpty
,
hideZero
}
=
this
.
panel
.
legend
;
const
{
alignAsTable
,
rightSide
,
sideWidth
,
sort
,
sortDesc
,
hideEmpty
,
hideZero
}
=
this
.
panel
.
legend
;
const
legendOptions
=
{
alignAsTable
,
rightSide
,
sideWidth
,
sort
,
sortDesc
,
hideEmpty
,
hideZero
};
const
legendOptions
=
{
alignAsTable
,
rightSide
,
sideWidth
,
sort
,
sortDesc
,
hideEmpty
,
hideZero
};
...
@@ -104,12 +105,9 @@ class GraphElement {
...
@@ -104,12 +105,9 @@ class GraphElement {
onColorChange
:
this
.
ctrl
.
onColorChange
,
onColorChange
:
this
.
ctrl
.
onColorChange
,
onToggleAxis
:
this
.
ctrl
.
onToggleAxis
,
onToggleAxis
:
this
.
ctrl
.
onToggleAxis
,
};
};
const
legendReactElem
=
React
.
createElement
(
Legend
,
legendProps
);
ReactDOM
.
render
(
legendReactElem
,
this
.
legendElem
,
()
=>
this
.
onLegendRenderingComplete
());
}
onLegendRenderingComplete
()
{
const
legendReactElem
=
React
.
createElement
(
Legend
,
legendProps
);
this
.
render_panel
(
);
ReactDOM
.
render
(
legendReactElem
,
this
.
legendElem
,
()
=>
this
.
renderPanel
()
);
}
}
onGraphHover
(
evt
)
{
onGraphHover
(
evt
)
{
...
@@ -281,7 +279,7 @@ class GraphElement {
...
@@ -281,7 +279,7 @@ class GraphElement {
}
}
// Function for rendering panel
// Function for rendering panel
render
_p
anel
()
{
render
P
anel
()
{
this
.
panelWidth
=
this
.
elem
.
width
();
this
.
panelWidth
=
this
.
elem
.
width
();
if
(
this
.
shouldAbortRender
())
{
if
(
this
.
shouldAbortRender
())
{
return
;
return
;
...
...
public/app/plugins/panel/graph/specs/graph.test.ts
View file @
1976e185
...
@@ -125,7 +125,7 @@ describe('grafanaGraph', () => {
...
@@ -125,7 +125,7 @@ describe('grafanaGraph', () => {
//Emulate functions called by event listeners
//Emulate functions called by event listeners
link
.
buildFlotPairs
(
link
.
data
);
link
.
buildFlotPairs
(
link
.
data
);
link
.
render
_p
anel
();
link
.
render
P
anel
();
ctx
.
plotData
=
ctrl
.
plot
.
mock
.
calls
[
0
][
1
];
ctx
.
plotData
=
ctrl
.
plot
.
mock
.
calls
[
0
][
1
];
ctx
.
plotOptions
=
ctrl
.
plot
.
mock
.
calls
[
0
][
2
];
ctx
.
plotOptions
=
ctrl
.
plot
.
mock
.
calls
[
0
][
2
];
...
...
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