mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
This commit is contained in:
parent
616d582d1c
commit
32a6200b22
2 changed files with 35 additions and 5 deletions
|
@ -33,6 +33,8 @@ import {
|
|||
SERIES_ID_ATTR,
|
||||
colors,
|
||||
Axis,
|
||||
ACTIVE_CURSOR,
|
||||
eventBus,
|
||||
} from '../helpers/panel_utils';
|
||||
|
||||
import { Series, Sheet } from '../helpers/timelion_request_handler';
|
||||
|
@ -338,16 +340,40 @@ function TimelionVisComponent({
|
|||
});
|
||||
}, [legendCaption, legendValueNumbers]);
|
||||
|
||||
const plotHoverHandler = useCallback(
|
||||
(event: JQuery.TriggeredEvent, pos: Position) => {
|
||||
if (!plot) {
|
||||
return;
|
||||
}
|
||||
const plotHover = useCallback(
|
||||
(pos: Position) => {
|
||||
(plot as CrosshairPlot).setCrosshair(pos);
|
||||
debouncedSetLegendNumbers(pos);
|
||||
},
|
||||
[plot, debouncedSetLegendNumbers]
|
||||
);
|
||||
|
||||
const plotHoverHandler = useCallback(
|
||||
(event: JQuery.TriggeredEvent, pos: Position) => {
|
||||
if (!plot) {
|
||||
return;
|
||||
}
|
||||
plotHover(pos);
|
||||
eventBus.trigger(ACTIVE_CURSOR, [event, pos]);
|
||||
},
|
||||
[plot, plotHover]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
const updateCursor = (_: any, event: JQuery.TriggeredEvent, pos: Position) => {
|
||||
if (!plot) {
|
||||
return;
|
||||
}
|
||||
plotHover(pos);
|
||||
};
|
||||
|
||||
eventBus.on(ACTIVE_CURSOR, updateCursor);
|
||||
|
||||
return () => {
|
||||
eventBus.off(ACTIVE_CURSOR, updateCursor);
|
||||
};
|
||||
}, [plot, plotHover]);
|
||||
|
||||
const mouseLeaveHandler = useCallback(() => {
|
||||
if (!plot) {
|
||||
return;
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
|
||||
import { cloneDeep, defaults, mergeWith, compact } from 'lodash';
|
||||
import $ from 'jquery';
|
||||
import moment, { Moment } from 'moment-timezone';
|
||||
|
||||
import { TimefilterContract } from 'src/plugins/data/public';
|
||||
|
@ -50,6 +51,9 @@ interface TimeRangeBounds {
|
|||
max: Moment | undefined;
|
||||
}
|
||||
|
||||
export const ACTIVE_CURSOR = 'ACTIVE_CURSOR_TIMELION';
|
||||
export const eventBus = $({});
|
||||
|
||||
const colors = [
|
||||
'#01A4A4',
|
||||
'#C66',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue