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
ab3860a3
Unverified
Commit
ab3860a3
authored
Apr 25, 2019
by
Ryan McKinley
Committed by
GitHub
Apr 25, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GraphLegendEditor: use stats picker rather than switches (#16759)
parent
78cd9058
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
38 deletions
+36
-38
public/app/plugins/panel/graph2/GraphLegendEditor.tsx
+34
-32
public/app/plugins/panel/graph2/GraphPanelEditor.tsx
+2
-6
No files found.
public/app/plugins/panel/graph2/GraphLegendEditor.tsx
View file @
ab3860a3
import
React
from
'react'
;
import
capitalize
from
'lodash/capitalize'
;
import
without
from
'lodash/without'
;
import
{
LegendOptions
,
PanelOptionsGroup
,
Switch
,
Input
}
from
'@grafana/ui'
;
import
{
LegendOptions
,
PanelOptionsGroup
,
Switch
,
Input
,
StatsPicker
}
from
'@grafana/ui'
;
export
interface
GraphLegendEditorLegendOptions
extends
LegendOptions
{
stats
?:
string
[];
...
...
@@ -11,29 +9,17 @@ export interface GraphLegendEditorLegendOptions extends LegendOptions {
}
interface
GraphLegendEditorProps
{
stats
:
string
[];
options
:
GraphLegendEditorLegendOptions
;
onChange
:
(
options
:
GraphLegendEditorLegendOptions
)
=>
void
;
}
export
const
GraphLegendEditor
:
React
.
FunctionComponent
<
GraphLegendEditorProps
>
=
props
=>
{
const
{
stats
,
options
,
onChange
}
=
props
;
const
{
options
,
onChange
}
=
props
;
const
onStatToggle
=
(
stat
:
string
)
=>
(
event
?:
React
.
SyntheticEvent
<
HTMLInputElement
>
)
=>
{
let
newStats
;
if
(
!
event
)
{
return
;
}
// @ts-ignore
if
(
event
.
target
.
checked
)
{
newStats
=
(
options
.
stats
||
[]).
concat
([
stat
]);
}
else
{
newStats
=
without
(
options
.
stats
,
stat
);
}
const
onStatsChanged
=
(
stats
:
string
[])
=>
{
onChange
({
...
options
,
stats
:
newStats
,
stats
,
});
};
...
...
@@ -56,26 +42,42 @@ export const GraphLegendEditor: React.FunctionComponent<GraphLegendEditorProps>
});
};
const
labelWidth
=
8
;
return
(
<
PanelOptionsGroup
title=
"Legend"
>
<
div
className=
"section gf-form-group"
>
<
h4
>
Options
</
h4
>
<
Switch
label=
"Show legend"
checked=
{
options
.
isVisible
}
onChange=
{
onOptionToggle
(
'isVisible'
)
}
/>
<
Switch
label=
"Display as table"
checked=
{
options
.
asTable
}
onChange=
{
onOptionToggle
(
'asTable'
)
}
/>
<
Switch
label=
"To the right"
checked=
{
options
.
placement
===
'right'
}
onChange=
{
onOptionToggle
(
'placement'
)
}
/>
<
Switch
label=
"Show legend"
labelClass=
{
`width-${labelWidth}`
}
checked=
{
options
.
isVisible
}
onChange=
{
onOptionToggle
(
'isVisible'
)
}
/>
<
Switch
label=
"Display as table"
labelClass=
{
`width-${labelWidth}`
}
checked=
{
options
.
asTable
}
onChange=
{
onOptionToggle
(
'asTable'
)
}
/>
<
Switch
label=
"To the right"
labelClass=
{
`width-${labelWidth}`
}
checked=
{
options
.
placement
===
'right'
}
onChange=
{
onOptionToggle
(
'placement'
)
}
/>
</
div
>
<
div
className=
"section gf-form-group"
>
<
h4
>
Values
</
h4
>
{
stats
.
map
(
stat
=>
{
return
(
<
Switch
label=
{
capitalize
(
stat
)
}
checked=
{
!!
options
.
stats
&&
options
.
stats
.
indexOf
(
stat
)
>
-
1
}
onChange=
{
onStatToggle
(
stat
)
}
key=
{
stat
}
/>
);
})
}
<
h4
>
Show
</
h4
>
<
div
className=
"gf-form"
>
<
StatsPicker
allowMultiple=
{
true
}
stats=
{
options
.
stats
?
options
.
stats
:
[]
}
onChange=
{
onStatsChanged
}
placeholder=
{
'Pick Values'
}
/>
</
div
>
<
div
className=
"gf-form"
>
<
div
className=
"gf-form-label"
>
Decimals
</
div
>
<
Input
...
...
public/app/plugins/panel/graph2/GraphPanelEditor.tsx
View file @
ab3860a3
...
...
@@ -3,7 +3,7 @@ import _ from 'lodash';
import
React
,
{
PureComponent
}
from
'react'
;
// Types
import
{
PanelEditorProps
,
Switch
,
LegendOptions
,
StatID
}
from
'@grafana/ui'
;
import
{
PanelEditorProps
,
Switch
,
LegendOptions
}
from
'@grafana/ui'
;
import
{
Options
,
GraphOptions
}
from
'./types'
;
import
{
GraphLegendEditor
}
from
'./GraphLegendEditor'
;
...
...
@@ -47,11 +47,7 @@ export class GraphPanelEditor extends PureComponent<PanelEditorProps<Options>> {
<
Switch
label=
"Bars"
labelClass=
"width-5"
checked=
{
showBars
}
onChange=
{
this
.
onToggleBars
}
/>
<
Switch
label=
"Points"
labelClass=
"width-5"
checked=
{
showPoints
}
onChange=
{
this
.
onTogglePoints
}
/>
</
div
>
<
GraphLegendEditor
stats=
{
[
StatID
.
min
,
StatID
.
max
,
StatID
.
mean
,
StatID
.
last
,
StatID
.
sum
]
}
options=
{
this
.
props
.
options
.
legend
}
onChange=
{
this
.
onLegendOptionsChange
}
/>
<
GraphLegendEditor
options=
{
this
.
props
.
options
.
legend
}
onChange=
{
this
.
onLegendOptionsChange
}
/>
</>
);
}
...
...
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