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
097396c5
Commit
097396c5
authored
Feb 05, 2019
by
Johannes Schill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: Replace withSize with AutoSizer in explore/Graph.tsx
parent
ae0b027d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
5 deletions
+23
-5
public/app/features/explore/Graph.test.tsx
+1
-0
public/app/features/explore/Graph.tsx
+22
-5
No files found.
public/app/features/explore/Graph.test.tsx
View file @
097396c5
...
...
@@ -5,6 +5,7 @@ import { mockData } from './__mocks__/mockData';
const
setup
=
(
propOverrides
?:
object
)
=>
{
const
props
=
{
size
:
{
width
:
10
,
height
:
20
},
data
:
mockData
().
slice
(
0
,
19
),
range
:
{
from
:
'now-6h'
,
to
:
'now'
},
...
propOverrides
,
...
...
public/app/features/explore/Graph.tsx
View file @
097396c5
import
$
from
'jquery'
;
import
React
,
{
PureComponent
}
from
'react'
;
import
moment
from
'moment'
;
import
{
withSize
}
from
'react-sizeme
'
;
import
{
AutoSizer
}
from
'react-virtualized
'
;
import
'vendor/flot/jquery.flot'
;
import
'vendor/flot/jquery.flot.time'
;
...
...
@@ -80,12 +80,15 @@ interface GraphProps {
id
?:
string
;
range
:
RawTimeRange
;
split
?:
boolean
;
size
?:
{
width
:
number
;
height
:
number
};
userOptions
?:
any
;
onChangeTime
?:
(
range
:
RawTimeRange
)
=>
void
;
onToggleSeries
?:
(
alias
:
string
,
hiddenSeries
:
Set
<
string
>
)
=>
void
;
}
interface
SizedGraphProps
extends
GraphProps
{
size
:
{
width
:
number
;
height
:
number
};
}
interface
GraphState
{
/**
* Type parameter refers to the `alias` property of a `TimeSeries`.
...
...
@@ -95,7 +98,7 @@ interface GraphState {
showAllTimeSeries
:
boolean
;
}
export
class
Graph
extends
PureComponent
<
GraphProps
,
GraphState
>
{
export
class
Graph
extends
PureComponent
<
Sized
GraphProps
,
GraphState
>
{
$el
:
any
;
dynamicOptions
=
null
;
...
...
@@ -116,7 +119,7 @@ export class Graph extends PureComponent<GraphProps, GraphState> {
this
.
$el
.
bind
(
'plotselected'
,
this
.
onPlotSelected
);
}
componentDidUpdate
(
prevProps
:
GraphProps
,
prevState
:
GraphState
)
{
componentDidUpdate
(
prevProps
:
Sized
GraphProps
,
prevState
:
GraphState
)
{
if
(
prevProps
.
data
!==
this
.
props
.
data
||
prevProps
.
range
!==
this
.
props
.
range
||
...
...
@@ -261,4 +264,18 @@ export class Graph extends PureComponent<GraphProps, GraphState> {
}
}
export
default
withSize
()(
Graph
);
export
default
(
props
:
GraphProps
)
=>
(
<
AutoSizer
>
{
({
width
,
height
})
=>
{
return
(
<
Graph
size=
{
{
width
:
width
,
height
:
height
}
}
{
...
props
}
/>
);
}
}
</
AutoSizer
>
);
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