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
810c327e
Unverified
Commit
810c327e
authored
Oct 06, 2020
by
Dominik Prokop
Committed by
GitHub
Oct 06, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use annotations data observable (#28050)
parent
aa6c98f7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
6 deletions
+9
-6
public/app/plugins/panel/graph3/plugins/AnnotationsPlugin.tsx
+9
-6
No files found.
public/app/plugins/panel/graph3/plugins/AnnotationsPlugin.tsx
View file @
810c327e
...
...
@@ -4,6 +4,7 @@ import { getAnnotationsFromData } from 'app/features/annotations/standardAnnotat
import
React
,
{
useCallback
,
useEffect
,
useMemo
,
useRef
,
useState
}
from
'react'
;
import
{
css
}
from
'emotion'
;
import
{
AnnotationMarker
}
from
'./AnnotationMarker'
;
import
{
useObservable
}
from
'react-use'
;
interface
AnnotationsPluginProps
{
annotations
:
DataFrame
[];
...
...
@@ -14,7 +15,7 @@ export const AnnotationsPlugin: React.FC<AnnotationsPluginProps> = ({ annotation
const
pluginId
=
'AnnotationsPlugin'
;
const
pluginsApi
=
usePlotPluginContext
();
const
plotContext
=
usePlotContext
();
const
annotationsRef
=
useRef
<
AnnotationEvent
[]
|
null
>
(
null
);
const
annotationsRef
=
useRef
<
AnnotationEvent
[]
>
(
);
const
[
renderCounter
,
setRenderCounter
]
=
useState
(
0
);
const
theme
=
useTheme
();
...
...
@@ -28,15 +29,17 @@ export const AnnotationsPlugin: React.FC<AnnotationsPluginProps> = ({ annotation
[
timeZone
]
);
const
annotationsData
=
useMemo
(()
=>
{
return
getAnnotationsFromData
(
annotations
);
},
[
annotations
]);
const
annotationEventsStream
=
useMemo
(()
=>
getAnnotationsFromData
(
annotations
),
[
annotations
]);
const
annotationsData
=
useObservable
<
AnnotationEvent
[]
>
(
annotationEventsStream
);
const
annotationMarkers
=
useMemo
(()
=>
{
if
(
!
plotContext
||
!
plotContext
?.
u
)
{
return
null
;
}
const
markers
=
[];
const
markers
:
AnnotationEvent
[]
=
[];
if
(
!
annotationsData
)
{
return
markers
;
}
for
(
let
i
=
0
;
i
<
annotationsData
.
length
;
i
++
)
{
const
annotation
=
annotationsData
[
i
];
...
...
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