Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
"@babel/core": "^7.9.0",
"@babel/register": "^7.9.0",
"@elastic/apm-rum": "^5.1.1",
"@elastic/charts": "18.4.2",
"@elastic/charts": "19.0.0",
"@elastic/datemath": "5.0.3",
"@elastic/ems-client": "7.8.0",
"@elastic/eui": "22.3.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-ui-shared-deps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"kbn:watch": "node scripts/build --watch"
},
"dependencies": {
"@elastic/charts": "18.4.2",
"@elastic/charts": "19.0.0",
"@elastic/eui": "22.3.0",
"@kbn/i18n": "1.0.0",
"abortcontroller-polyfill": "^1.4.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {
TooltipType,
ElementClickListener,
XYChartElementEvent,
BrushEndListener,
} from '@elastic/charts';

import { i18n } from '@kbn/i18n';
Expand Down Expand Up @@ -143,13 +144,12 @@ export class DiscoverHistogram extends Component<DiscoverHistogramProps, Discove
}
}

public onBrushEnd = (min: number, max: number) => {
const range = {
from: min,
to: max,
};

this.props.timefilterUpdateHandler(range);
public onBrushEnd: BrushEndListener = ({ x }) => {
if (!x) {
return;
}
const [from, to] = x;
this.props.timefilterUpdateHandler({ from, to });
};

public onElementClick = (xInterval: number): ElementClickListener => ([elementData]) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,21 @@ export const TimeSeries = ({
const { colors } = getChartsSetup();
colors.mappedColors.mapKeys(series.filter(({ color }) => !color).map(({ label }) => label));

const onBrushEndListener = ({ x }) => {
if (!x) {
return;
}
const [min, max] = x;
onBrush(min, max);
};

return (
<Chart ref={chartRef} renderer="canvas" className={classes}>
<Settings
showLegend={legend}
showLegendExtra={true}
legendPosition={legendPosition}
onBrushEnd={onBrush}
onBrushEnd={onBrushEndListener}
animateData={false}
onPointerUpdate={handleCursorUpdate}
theme={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
LIGHT_THEME,
DARK_THEME,
RectAnnotation,
BrushEndListener,
} from '@elastic/charts';
import numeral from '@elastic/numeral';
import { i18n } from '@kbn/i18n';
Expand Down Expand Up @@ -53,8 +54,12 @@ export const AnomaliesChart: React.FunctionComponent<{
[dateFormat]
);

const handleBrushEnd = useCallback(
(startTime: number, endTime: number) => {
const handleBrushEnd = useCallback<BrushEndListener>(
({ x }) => {
if (!x) {
return;
}
const [startTime, endTime] = x;
setTimeRange({
endTime,
startTime,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
niceTimeFormatter,
Settings,
TooltipValue,
BrushEndListener,
LIGHT_THEME,
DARK_THEME,
} from '@elastic/charts';
Expand Down Expand Up @@ -43,8 +44,12 @@ export const LogEntryRateBarChart: React.FunctionComponent<{
[dateFormat]
);

const handleBrushEnd = useCallback(
(startTime: number, endTime: number) => {
const handleBrushEnd = useCallback<BrushEndListener>(
({ x }) => {
if (!x) {
return;
}
const [startTime, endTime] = x;
setTimeRange({
endTime,
startTime,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@
import React, { useCallback, useMemo } from 'react';
import moment from 'moment';
import { i18n } from '@kbn/i18n';
import { Axis, Chart, niceTimeFormatter, Position, Settings, TooltipValue } from '@elastic/charts';
import {
Axis,
Chart,
niceTimeFormatter,
Position,
Settings,
TooltipValue,
BrushEndListener,
} from '@elastic/charts';
import { EuiPageContentBody } from '@elastic/eui';
import { getChartTheme } from '../../metrics_explorer/components/helpers/get_chart_theme';
import { SeriesChart } from './series_chart';
Expand Down Expand Up @@ -45,8 +53,12 @@ export const ChartSectionVis = ({
() => (metric != null ? niceTimeFormatter(getMaxMinTimestamp(metric)) : undefined),
[metric]
);
const handleTimeChange = useCallback(
(from: number, to: number) => {
const handleTimeChange = useCallback<BrushEndListener>(
({ x }) => {
if (!x) {
return;
}
const [from, to] = x;
if (onChangeRangeTime) {
if (isLiveStreaming && stopLiveStreaming) {
stopLiveStreaming();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,15 @@
import React, { useCallback, useMemo } from 'react';

import { EuiTitle, EuiToolTip, EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import { Axis, Chart, niceTimeFormatter, Position, Settings, TooltipValue } from '@elastic/charts';
import {
Axis,
Chart,
niceTimeFormatter,
Position,
Settings,
TooltipValue,
BrushEndListener,
} from '@elastic/charts';
import { first, last } from 'lodash';
import moment from 'moment';
import { MetricsExplorerSeries } from '../../../../../common/http_api/metrics_explorer';
Expand Down Expand Up @@ -58,7 +66,11 @@ export const MetricsExplorerChart = ({
const isDarkMode = useUiSetting<boolean>('theme:darkMode');
const { metrics } = options;
const [dateFormat] = useKibanaUiSetting('dateFormat');
const handleTimeChange = (from: number, to: number) => {
const handleTimeChange: BrushEndListener = ({ x }) => {
if (!x) {
return;
}
const [from, to] = x;
onTimeChange(moment(from).toISOString(), moment(to).toISOString());
};
const dateFormatter = useMemo(
Expand Down
70 changes: 0 additions & 70 deletions x-pack/plugins/infra/types/eui_experimental.d.ts

This file was deleted.

3 changes: 2 additions & 1 deletion x-pack/plugins/siem/public/components/charts/common.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
SettingsSpecProps,
TickFormatter,
Position,
BrushEndListener,
} from '@elastic/charts';
import React, { useMemo } from 'react';
import styled from 'styled-components';
Expand All @@ -27,7 +28,7 @@ export const defaultChartWidth = '100%';
const chartDefaultRotation: Rotation = 0;
const chartDefaultRendering: Rendering = 'canvas';

export type UpdateDateRange = (min: number, max: number) => void;
export type UpdateDateRange = BrushEndListener;

export interface ChartData {
x?: number | string | null;
Expand Down
10 changes: 7 additions & 3 deletions x-pack/plugins/siem/public/components/matrix_histogram/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,15 @@ export const MatrixHistogramComponent: React.FC<MatrixHistogramProps &
from: startDate,
legendPosition,
to: endDate,
onBrushEnd: (min: number, max: number) => {
onBrushEnd: ({ x }) => {
if (!x) {
return;
}
const [from, to] = x;
dispatchSetAbsoluteRangeDatePicker({
id: setAbsoluteRangeDatePickerTarget,
from: min,
to: max,
from,
to,
});
},
yTickFormatter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { isEmpty } from 'lodash/fp';
import uuid from 'uuid';

import { DEFAULT_NUMBER_FORMAT } from '../../../../../common/constants';
import { UpdateDateRange } from '../../../../components/charts/common';
import { LegendItem } from '../../../../components/charts/draggable_legend_item';
import { escapeDataProviderId } from '../../../../components/drag_and_drop/helpers';
import { HeaderSection } from '../../../../components/header_section';
Expand Down Expand Up @@ -70,7 +71,7 @@ interface SignalsHistogramPanelProps {
stackByOptions?: SignalsHistogramOption[];
title?: string;
to: number;
updateDateRange: (min: number, max: number) => void;
updateDateRange: UpdateDateRange;
}

const getHistogramOption = (fieldName: string): MatrixHistogramOption => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
import { EuiFlexGroup, EuiFlexItem, EuiProgress } from '@elastic/eui';
import React, { useMemo } from 'react';

import { useTheme } from '../../../../components/charts/common';
import { useTheme, UpdateDateRange } from '../../../../components/charts/common';
import { histogramDateTimeFormatter } from '../../../../components/utils';
import { DraggableLegend } from '../../../../components/charts/draggable_legend';
import { LegendItem } from '../../../../components/charts/draggable_legend_item';
Expand All @@ -32,7 +32,7 @@ interface HistogramSignalsProps {
loading: boolean;
to: number;
data: HistogramData[];
updateDateRange: (min: number, max: number) => void;
updateDateRange: UpdateDateRange;
}
export const SignalsHistogram = React.memo<HistogramSignalsProps>(
({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { connect, ConnectedProps } from 'react-redux';
import { GlobalTime } from '../../containers/global_time';
import { indicesExistOrDataTemporarilyUnavailable, WithSource } from '../../containers/source';
import { AlertsTable } from '../../components/alerts_viewer/alerts_table';
import { UpdateDateRange } from '../../components/charts/common';
import { FiltersGlobal } from '../../components/filters_global';
import {
getDetectionEngineTabUrl,
Expand Down Expand Up @@ -77,8 +78,12 @@ export const DetectionEnginePageComponent: React.FC<PropsFromRedux> = ({

const [lastSignals] = useSignalInfo({});

const updateDateRangeCallback = useCallback(
(min: number, max: number) => {
const updateDateRangeCallback = useCallback<UpdateDateRange>(
({ x }) => {
if (!x) {
return;
}
const [min, max] = x;
setAbsoluteRangeDatePicker({ id: 'global', from: min, to: max });
},
[setAbsoluteRangeDatePicker]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { Redirect, useParams } from 'react-router-dom';
import { StickyContainer } from 'react-sticky';
import { connect, ConnectedProps } from 'react-redux';

import { UpdateDateRange } from '../../../../components/charts/common';
import { FiltersGlobal } from '../../../../components/filters_global';
import { FormattedDate } from '../../../../components/formatted_date';
import {
Expand Down Expand Up @@ -209,8 +210,12 @@ export const RuleDetailsPageComponent: FC<PropsFromRedux> = ({
signalIndexName,
]);

const updateDateRangeCallback = useCallback(
(min: number, max: number) => {
const updateDateRangeCallback = useCallback<UpdateDateRange>(
({ x }) => {
if (!x) {
return;
}
const [min, max] = x;
setAbsoluteRangeDatePicker({ id: 'global', from: min, to: max });
},
[setAbsoluteRangeDatePicker]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import React, { useCallback } from 'react';
import { Route, Switch } from 'react-router-dom';

import { UpdateDateRange } from '../../../components/charts/common';
import { scoreIntervalToDateTime } from '../../../components/ml/score/score_interval_to_datetime';
import { Anomaly } from '../../../components/ml/types';
import { HostsTableType } from '../../../store/hosts/model';
Expand Down Expand Up @@ -50,8 +51,12 @@ export const HostDetailsTabs = React.memo<HostDetailsTabsProps>(
[setAbsoluteRangeDatePicker]
);

const updateDateRange = useCallback(
(min: number, max: number) => {
const updateDateRange = useCallback<UpdateDateRange>(
({ x }) => {
if (!x) {
return;
}
const [min, max] = x;
setAbsoluteRangeDatePicker({ id: 'global', from: min, to: max });
},
[setAbsoluteRangeDatePicker]
Expand Down
Loading