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
d1d5bbf6
Unverified
Commit
d1d5bbf6
authored
Feb 01, 2019
by
Torkel Ödegaard
Committed by
GitHub
Feb 01, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #15188 from grafana/fix/table-data-to-component
React panel table data fix
parents
68ae17e4
57596462
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
37 additions
and
42 deletions
+37
-42
packages/grafana-ui/src/components/Gauge/Gauge.test.tsx
+1
-2
packages/grafana-ui/src/components/Gauge/Gauge.tsx
+4
-22
packages/grafana-ui/src/types/panel.ts
+1
-1
public/app/features/dashboard/dashgrid/PanelChrome.tsx
+3
-3
public/app/plugins/panel/gauge/GaugePanel.tsx
+20
-9
public/app/plugins/panel/graph2/GraphPanel.tsx
+8
-5
No files found.
packages/grafana-ui/src/components/Gauge/Gauge.test.tsx
View file @
d1d5bbf6
...
...
@@ -2,7 +2,6 @@ import React from 'react';
import
{
shallow
}
from
'enzyme'
;
import
{
Gauge
,
Props
}
from
'./Gauge'
;
import
{
TimeSeriesVMs
}
from
'../../types/data'
;
import
{
ValueMapping
,
MappingType
}
from
'../../types'
;
jest
.
mock
(
'jquery'
,
()
=>
({
...
...
@@ -23,7 +22,7 @@ const setup = (propOverrides?: object) => {
stat
:
'avg'
,
height
:
300
,
width
:
300
,
timeSeries
:
{}
as
TimeSeriesVMs
,
value
:
25
,
decimals
:
0
,
};
...
...
packages/grafana-ui/src/components/Gauge/Gauge.tsx
View file @
d1d5bbf6
import
React
,
{
PureComponent
}
from
'react'
;
import
$
from
'jquery'
;
import
{
ValueMapping
,
Threshold
,
BasicGaugeColor
,
TimeSeriesVMs
,
GrafanaTheme
}
from
'../../types'
;
import
{
ValueMapping
,
Threshold
,
BasicGaugeColor
,
GrafanaTheme
}
from
'../../types'
;
import
{
getMappedValue
}
from
'../../utils/valueMappings'
;
import
{
getColorFromHexRgbOrName
,
getValueFormat
}
from
'../../utils'
;
...
...
@@ -14,7 +14,6 @@ export interface Props {
maxValue
:
number
;
minValue
:
number
;
prefix
:
string
;
timeSeries
:
TimeSeriesVMs
;
thresholds
:
Threshold
[];
showThresholdMarkers
:
boolean
;
showThresholdLabels
:
boolean
;
...
...
@@ -22,6 +21,7 @@ export interface Props {
suffix
:
string
;
unit
:
string
;
width
:
number
;
value
:
number
;
theme
?:
GrafanaTheme
;
}
...
...
@@ -122,25 +122,7 @@ export class Gauge extends PureComponent<Props> {
}
draw
()
{
const
{
maxValue
,
minValue
,
timeSeries
,
showThresholdLabels
,
showThresholdMarkers
,
width
,
height
,
stat
,
theme
,
}
=
this
.
props
;
let
value
:
TimeSeriesValue
=
''
;
if
(
timeSeries
[
0
])
{
value
=
timeSeries
[
0
].
stats
[
stat
];
}
else
{
value
=
null
;
}
const
{
maxValue
,
minValue
,
showThresholdLabels
,
showThresholdMarkers
,
width
,
height
,
theme
,
value
}
=
this
.
props
;
const
formattedValue
=
this
.
formatValue
(
value
)
as
string
;
const
dimension
=
Math
.
min
(
width
,
height
*
1.3
);
...
...
@@ -194,7 +176,7 @@ export class Gauge extends PureComponent<Props> {
try
{
$
.
plot
(
this
.
canvasElement
,
[
plotSeries
],
options
);
}
catch
(
err
)
{
console
.
log
(
'Gauge rendering error'
,
err
,
options
,
timeSeries
);
console
.
log
(
'Gauge rendering error'
,
err
,
options
,
value
);
}
}
...
...
packages/grafana-ui/src/types/panel.ts
View file @
d1d5bbf6
...
...
@@ -4,7 +4,7 @@ import { TimeRange } from './time';
export
type
InterpolateFunction
=
(
value
:
string
,
format
?:
string
|
Function
)
=>
string
;
export
interface
PanelProps
<
T
=
any
>
{
timeSeries
:
TimeSeries
[]
;
panelData
:
PanelData
;
timeRange
:
TimeRange
;
loading
:
LoadingState
;
options
:
T
;
...
...
public/app/features/dashboard/dashgrid/PanelChrome.tsx
View file @
d1d5bbf6
...
...
@@ -94,7 +94,7 @@ export class PanelChrome extends PureComponent<Props, State> {
return
!
this
.
props
.
dashboard
.
otherPanelInFullscreen
(
this
.
props
.
panel
);
}
renderPanel
(
loading
,
timeSeries
,
width
,
height
):
JSX
.
Element
{
renderPanel
(
loading
,
panelData
,
width
,
height
):
JSX
.
Element
{
const
{
panel
,
plugin
}
=
this
.
props
;
const
{
timeRange
,
renderCounter
}
=
this
.
state
;
const
PanelComponent
=
plugin
.
exports
.
Panel
;
...
...
@@ -109,7 +109,7 @@ export class PanelChrome extends PureComponent<Props, State> {
<
div
className=
"panel-content"
>
<
PanelComponent
loading=
{
loading
}
timeSeries=
{
timeSeries
}
panelData=
{
panelData
}
timeRange=
{
timeRange
}
options=
{
panel
.
getOptions
(
plugin
.
exports
.
PanelDefaults
)
}
width=
{
width
-
2
*
variables
.
panelHorizontalPadding
}
...
...
@@ -158,7 +158,7 @@ export class PanelChrome extends PureComponent<Props, State> {
onDataResponse=
{
this
.
onDataResponse
}
>
{
({
loading
,
panelData
})
=>
{
return
this
.
renderPanel
(
loading
,
panelData
.
timeSeries
,
width
,
height
);
return
this
.
renderPanel
(
loading
,
panelData
,
width
,
height
);
}
}
</
DataPanel
>
)
}
...
...
public/app/plugins/panel/gauge/GaugePanel.tsx
View file @
d1d5bbf6
...
...
@@ -9,28 +9,39 @@ import { Gauge } from '@grafana/ui';
// Types
import
{
GaugeOptions
}
from
'./types'
;
import
{
PanelProps
,
NullValueMode
}
from
'@grafana/ui/src/types'
;
import
{
PanelProps
,
NullValueMode
,
TimeSeriesValue
}
from
'@grafana/ui/src/types'
;
import
{
ThemeProvider
}
from
'app/core/utils/ConfigProvider'
;
interface
Props
extends
PanelProps
<
GaugeOptions
>
{}
export
class
GaugePanel
extends
PureComponent
<
Props
>
{
render
()
{
const
{
timeSeries
,
width
,
height
,
onInterpolate
,
options
}
=
this
.
props
;
const
{
panelData
,
width
,
height
,
onInterpolate
,
options
}
=
this
.
props
;
const
prefix
=
onInterpolate
(
options
.
prefix
);
const
suffix
=
onInterpolate
(
options
.
suffix
);
const
vmSeries
=
processTimeSeries
({
timeSeries
:
timeSeries
,
nullValueMode
:
NullValueMode
.
Null
,
});
let
value
:
TimeSeriesValue
;
if
(
panelData
.
timeSeries
)
{
const
vmSeries
=
processTimeSeries
({
timeSeries
:
panelData
.
timeSeries
,
nullValueMode
:
NullValueMode
.
Null
,
});
if
(
vmSeries
[
0
])
{
value
=
vmSeries
[
0
].
stats
[
options
.
stat
];
}
else
{
value
=
null
;
}
}
else
if
(
panelData
.
tableData
)
{
value
=
panelData
.
tableData
.
rows
[
0
].
find
(
prop
=>
prop
>
0
);
}
return
(
<
ThemeProvider
>
{
(
theme
)
=>
(
{
theme
=>
(
<
Gauge
timeSeries=
{
vmSeries
}
value=
{
value
}
{
...
this
.
props
.
options
}
width=
{
width
}
height=
{
height
}
...
...
public/app/plugins/panel/graph2/GraphPanel.tsx
View file @
d1d5bbf6
...
...
@@ -16,13 +16,16 @@ interface Props extends PanelProps<Options> {}
export
class
GraphPanel
extends
PureComponent
<
Props
>
{
render
()
{
const
{
timeSeries
,
timeRange
,
width
,
height
}
=
this
.
props
;
const
{
panelData
,
timeRange
,
width
,
height
}
=
this
.
props
;
const
{
showLines
,
showBars
,
showPoints
}
=
this
.
props
.
options
;
const
vmSeries
=
processTimeSeries
({
timeSeries
:
timeSeries
,
nullValueMode
:
NullValueMode
.
Ignore
,
});
let
vmSeries
;
if
(
panelData
.
timeSeries
)
{
vmSeries
=
processTimeSeries
({
timeSeries
:
panelData
.
timeSeries
,
nullValueMode
:
NullValueMode
.
Ignore
,
});
}
return
(
<
Graph
...
...
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