diff --git a/x-pack/plugins/apm/public/components/app/TransactionDetails/index.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/index.tsx
index 8a99773a97baf..8f335ddc71c72 100644
--- a/x-pack/plugins/apm/public/components/app/TransactionDetails/index.tsx
+++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/index.tsx
@@ -25,7 +25,7 @@ import { TransactionCharts } from '../../shared/charts/transaction_charts';
import { TransactionDistribution } from './Distribution';
import { WaterfallWithSummmary } from './WaterfallWithSummmary';
import { FETCH_STATUS } from '../../../hooks/useFetcher';
-import { ChartsSyncContextProvider } from '../../../context/charts_sync_context';
+import { ChartPointerEventContextProvider } from '../../../context/chart_pointer_event_context';
import { useTrackPageview } from '../../../../../observability/public';
import { Projection } from '../../../../common/projections';
import { fromQuery, toQuery } from '../../shared/Links/url_helpers';
@@ -125,13 +125,13 @@ export function TransactionDetails({
-
+
-
+
diff --git a/x-pack/plugins/apm/public/components/app/service_metrics/index.tsx b/x-pack/plugins/apm/public/components/app/service_metrics/index.tsx
index 5dc1645a1760d..d0f8fc1e61332 100644
--- a/x-pack/plugins/apm/public/components/app/service_metrics/index.tsx
+++ b/x-pack/plugins/apm/public/components/app/service_metrics/index.tsx
@@ -16,7 +16,7 @@ import React, { useMemo } from 'react';
import { useServiceMetricCharts } from '../../../hooks/useServiceMetricCharts';
import { MetricsChart } from '../../shared/charts/metrics_chart';
import { useUrlParams } from '../../../hooks/useUrlParams';
-import { ChartsSyncContextProvider } from '../../../context/charts_sync_context';
+import { ChartPointerEventContextProvider } from '../../../context/chart_pointer_event_context';
import { Projection } from '../../../../common/projections';
import { LocalUIFilters } from '../../shared/LocalUIFilters';
import { SearchBar } from '../../shared/search_bar';
@@ -57,7 +57,7 @@ export function ServiceMetrics({
-
+
{data.charts.map((chart) => (
@@ -73,7 +73,7 @@ export function ServiceMetrics({
))}
-
+
diff --git a/x-pack/plugins/apm/public/components/app/service_node_metrics/index.tsx b/x-pack/plugins/apm/public/components/app/service_node_metrics/index.tsx
index 59e919199be76..a74ff574bc0c8 100644
--- a/x-pack/plugins/apm/public/components/app/service_node_metrics/index.tsx
+++ b/x-pack/plugins/apm/public/components/app/service_node_metrics/index.tsx
@@ -22,7 +22,7 @@ import React from 'react';
import { RouteComponentProps } from 'react-router-dom';
import styled from 'styled-components';
import { SERVICE_NODE_NAME_MISSING } from '../../../../common/service_nodes';
-import { ChartsSyncContextProvider } from '../../../context/charts_sync_context';
+import { ChartPointerEventContextProvider } from '../../../context/chart_pointer_event_context';
import { useAgentName } from '../../../hooks/useAgentName';
import { FETCH_STATUS, useFetcher } from '../../../hooks/useFetcher';
import { useServiceMetricCharts } from '../../../hooks/useServiceMetricCharts';
@@ -178,7 +178,7 @@ export function ServiceNodeMetrics({ match }: ServiceNodeMetricsProps) {
)}
{agentName && (
-
+
{data.charts.map((chart) => (
@@ -194,12 +194,12 @@ export function ServiceNodeMetrics({ match }: ServiceNodeMetricsProps) {
))}
-
+
)}
{agentName && (
-
+
{data.charts.map((chart) => (
@@ -215,7 +215,7 @@ export function ServiceNodeMetrics({ match }: ServiceNodeMetricsProps) {
))}
-
+
)}
>
diff --git a/x-pack/plugins/apm/public/components/app/service_overview/index.tsx b/x-pack/plugins/apm/public/components/app/service_overview/index.tsx
index 33027f3946d1f..ddf3107a8ab1e 100644
--- a/x-pack/plugins/apm/public/components/app/service_overview/index.tsx
+++ b/x-pack/plugins/apm/public/components/app/service_overview/index.tsx
@@ -15,7 +15,7 @@ import { i18n } from '@kbn/i18n';
import React from 'react';
import { useTrackPageview } from '../../../../../observability/public';
import { isRumAgentName } from '../../../../common/agent_name';
-import { ChartsSyncContextProvider } from '../../../context/charts_sync_context';
+import { ChartPointerEventContextProvider } from '../../../context/chart_pointer_event_context';
import { TransactionBreakdownChart } from '../../shared/charts/transaction_breakdown_chart';
import { TransactionErrorRateChart } from '../../shared/charts/transaction_error_rate_chart';
import { ServiceMapLink } from '../../shared/Links/apm/ServiceMapLink';
@@ -43,7 +43,7 @@ export function ServiceOverview({
useTrackPageview({ app: 'apm', path: 'service_overview', delay: 15000 });
return (
-
+
@@ -170,6 +170,6 @@ export function ServiceOverview({
-
+
);
}
diff --git a/x-pack/plugins/apm/public/components/shared/charts/timeseries_chart.tsx b/x-pack/plugins/apm/public/components/shared/charts/timeseries_chart.tsx
index fe3d9a1edc1fb..c4f5abe104aa9 100644
--- a/x-pack/plugins/apm/public/components/shared/charts/timeseries_chart.tsx
+++ b/x-pack/plugins/apm/public/components/shared/charts/timeseries_chart.tsx
@@ -24,7 +24,7 @@ import { useChartTheme } from '../../../../../observability/public';
import { TimeSeries } from '../../../../typings/timeseries';
import { FETCH_STATUS } from '../../../hooks/useFetcher';
import { useUrlParams } from '../../../hooks/useUrlParams';
-import { useChartsSync } from '../../../hooks/use_charts_sync';
+import { useChartPointerEvent } from '../../../hooks/use_chart_pointer_event';
import { unit } from '../../../style/variables';
import { Annotations } from './annotations';
import { ChartContainer } from './chart_container';
@@ -60,15 +60,15 @@ export function TimeseriesChart({
const history = useHistory();
const chartRef = React.createRef();
const chartTheme = useChartTheme();
- const { event, setEvent } = useChartsSync();
+ const { pointerEvent, setPointerEvent } = useChartPointerEvent();
const { urlParams } = useUrlParams();
const { start, end } = urlParams;
useEffect(() => {
- if (event.chartId !== id && chartRef.current) {
- chartRef.current.dispatchExternalPointerEvent(event);
+ if (pointerEvent && pointerEvent?.chartId !== id && chartRef.current) {
+ chartRef.current.dispatchExternalPointerEvent(pointerEvent);
}
- }, [event, chartRef, id]);
+ }, [pointerEvent, chartRef, id]);
const min = moment.utc(start).valueOf();
const max = moment.utc(end).valueOf();
@@ -89,9 +89,7 @@ export function TimeseriesChart({
onBrushEnd({ x, history })}
theme={chartTheme}
- onPointerUpdate={(currEvent: any) => {
- setEvent(currEvent);
- }}
+ onPointerUpdate={setPointerEvent}
externalPointerEvents={{
tooltip: { visible: true, placement: Placement.Bottom },
}}
diff --git a/x-pack/plugins/apm/public/components/shared/charts/transaction_breakdown_chart/transaction_breakdown_chart_contents.tsx b/x-pack/plugins/apm/public/components/shared/charts/transaction_breakdown_chart/transaction_breakdown_chart_contents.tsx
index 8070868f831b2..04c07c01442a4 100644
--- a/x-pack/plugins/apm/public/components/shared/charts/transaction_breakdown_chart/transaction_breakdown_chart_contents.tsx
+++ b/x-pack/plugins/apm/public/components/shared/charts/transaction_breakdown_chart/transaction_breakdown_chart_contents.tsx
@@ -23,7 +23,7 @@ import { asPercent } from '../../../../../common/utils/formatters';
import { TimeSeries } from '../../../../../typings/timeseries';
import { FETCH_STATUS } from '../../../../hooks/useFetcher';
import { useUrlParams } from '../../../../hooks/useUrlParams';
-import { useChartsSync as useChartsSync2 } from '../../../../hooks/use_charts_sync';
+import { useChartPointerEvent } from '../../../../hooks/use_chart_pointer_event';
import { unit } from '../../../../style/variables';
import { Annotations } from '../../charts/annotations';
import { ChartContainer } from '../../charts/chart_container';
@@ -45,15 +45,19 @@ export function TransactionBreakdownChartContents({
const history = useHistory();
const chartRef = React.createRef();
const chartTheme = useChartTheme();
- const { event, setEvent } = useChartsSync2();
+ const { pointerEvent, setPointerEvent } = useChartPointerEvent();
const { urlParams } = useUrlParams();
const { start, end } = urlParams;
useEffect(() => {
- if (event.chartId !== 'timeSpentBySpan' && chartRef.current) {
- chartRef.current.dispatchExternalPointerEvent(event);
+ if (
+ pointerEvent &&
+ pointerEvent.chartId !== 'timeSpentBySpan' &&
+ chartRef.current
+ ) {
+ chartRef.current.dispatchExternalPointerEvent(pointerEvent);
}
- }, [chartRef, event]);
+ }, [chartRef, pointerEvent]);
const min = moment.utc(start).valueOf();
const max = moment.utc(end).valueOf();
@@ -71,9 +75,7 @@ export function TransactionBreakdownChartContents({
theme={chartTheme}
xDomain={{ min, max }}
flatLegend
- onPointerUpdate={(currEvent: any) => {
- setEvent(currEvent);
- }}
+ onPointerUpdate={setPointerEvent}
externalPointerEvents={{
tooltip: { visible: true, placement: Placement.Bottom },
}}
diff --git a/x-pack/plugins/apm/public/components/shared/charts/transaction_charts/index.tsx b/x-pack/plugins/apm/public/components/shared/charts/transaction_charts/index.tsx
index 3af081c11c9b1..221f17bb9e1d5 100644
--- a/x-pack/plugins/apm/public/components/shared/charts/transaction_charts/index.tsx
+++ b/x-pack/plugins/apm/public/components/shared/charts/transaction_charts/index.tsx
@@ -20,7 +20,7 @@ import {
TRANSACTION_ROUTE_CHANGE,
} from '../../../../../common/transaction_types';
import { asTransactionRate } from '../../../../../common/utils/formatters';
-import { ChartsSyncContextProvider } from '../../../../context/charts_sync_context';
+import { ChartPointerEventContextProvider } from '../../../../context/chart_pointer_event_context';
import { LicenseContext } from '../../../../context/LicenseContext';
import { IUrlParams } from '../../../../context/UrlParamsContext/types';
import { FETCH_STATUS } from '../../../../hooks/useFetcher';
@@ -51,7 +51,7 @@ export function TransactionCharts({
return (
<>
-
+
@@ -109,7 +109,7 @@ export function TransactionCharts({
-
+
>
);
}
diff --git a/x-pack/plugins/apm/public/context/charts_sync_context.tsx b/x-pack/plugins/apm/public/context/chart_pointer_event_context.tsx
similarity index 52%
rename from x-pack/plugins/apm/public/context/charts_sync_context.tsx
rename to x-pack/plugins/apm/public/context/chart_pointer_event_context.tsx
index d983a857a26ec..ea60206463258 100644
--- a/x-pack/plugins/apm/public/context/charts_sync_context.tsx
+++ b/x-pack/plugins/apm/public/context/chart_pointer_event_context.tsx
@@ -12,21 +12,23 @@ import React, {
useState,
} from 'react';
-export const ChartsSyncContext = createContext<{
- event: any;
- setEvent: Dispatch>;
+import { PointerEvent } from '@elastic/charts';
+
+export const ChartPointerEventContext = createContext<{
+ pointerEvent: PointerEvent | null;
+ setPointerEvent: Dispatch>;
} | null>(null);
-export function ChartsSyncContextProvider({
+export function ChartPointerEventContextProvider({
children,
}: {
children: ReactNode;
}) {
- const [event, setEvent] = useState({});
+ const [pointerEvent, setPointerEvent] = useState(null);
return (
-
);
diff --git a/x-pack/plugins/apm/public/hooks/use_charts_sync.tsx b/x-pack/plugins/apm/public/hooks/use_chart_pointer_event.tsx
similarity index 56%
rename from x-pack/plugins/apm/public/hooks/use_charts_sync.tsx
rename to x-pack/plugins/apm/public/hooks/use_chart_pointer_event.tsx
index cde5c84a6097b..058ec594e2d22 100644
--- a/x-pack/plugins/apm/public/hooks/use_charts_sync.tsx
+++ b/x-pack/plugins/apm/public/hooks/use_chart_pointer_event.tsx
@@ -5,13 +5,13 @@
*/
import { useContext } from 'react';
-import { ChartsSyncContext } from '../context/charts_sync_context';
+import { ChartPointerEventContext } from '../context/chart_pointer_event_context';
-export function useChartsSync() {
- const context = useContext(ChartsSyncContext);
+export function useChartPointerEvent() {
+ const context = useContext(ChartPointerEventContext);
if (!context) {
- throw new Error('Missing ChartsSync context provider');
+ throw new Error('Missing ChartPointerEventContext provider');
}
return context;