Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependency @elastic/charts to v57.0.1 (main) #155749

Merged
merged 13 commits into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -94,7 +94,7 @@
"@dnd-kit/utilities": "^2.0.0",
"@elastic/apm-rum": "^5.12.0",
"@elastic/apm-rum-react": "^1.4.2",
"@elastic/charts": "55.0.0",
"@elastic/charts": "57.0.1",
"@elastic/datemath": "5.0.3",
"@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@8.8.0-canary.2",
"@elastic/ems-client": "8.4.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,13 @@ import {
Position,
ScaleType,
Settings,
TooltipValue,
TooltipValueFormatter,
TooltipHeaderFormatter,
} from '@elastic/charts';

import { MetricDistributionChartTooltipHeader } from './metric_distribution_chart_tooltip_header';
import { kibanaFieldFormat } from '../../../utils';
import { useDataVizChartTheme } from '../../hooks';

interface ChartTooltipValue extends TooltipValue {
skipHeader?: boolean;
}

export interface MetricDistributionChartData {
x: number;
y: number;
Expand Down Expand Up @@ -66,7 +61,7 @@ export const MetricDistributionChart: FC<Props> = ({

const theme = useDataVizChartTheme();

const headerFormatter: TooltipValueFormatter = (tooltipData: ChartTooltipValue) => {
const headerFormatter: TooltipHeaderFormatter = (tooltipData) => {
const xValue = tooltipData.value;
const chartPoint: MetricDistributionChartData | undefined = chartData.find(
Comment on lines -69 to 66
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No functional change here, the tooltipData.value still points to the x value. Just simplifies headerFormatter, see elastic/elastic-charts#1989 for more context.

(data) => data.x === xValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import React, { useMemo } from 'react';
import { niceTimeFormatter, TooltipValue } from '@elastic/charts';
import { niceTimeFormatter, TooltipProps } from '@elastic/charts';
import moment from 'moment';
import { i18n } from '@kbn/i18n';
import { EuiLoadingChart, EuiText } from '@elastic/eui';
Expand All @@ -17,9 +17,8 @@ import { GetLogAlertsChartPreviewDataSuccessResponsePayload } from '../../../../

type Series = GetLogAlertsChartPreviewDataSuccessResponsePayload['data']['series'];

export const tooltipProps = {
headerFormatter: (tooltipValue: TooltipValue) =>
moment(tooltipValue.value).format('Y-MM-DD HH:mm:ss'),
export const tooltipProps: TooltipProps = {
headerFormatter: ({ value }) => moment(value).format('Y-MM-DD HH:mm:ss'),
};

export const NUM_BUCKETS = 20;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
Position,
Settings,
TickFormatter,
TooltipValue,
TooltipProps,
} from '@elastic/charts';
import moment from 'moment';
import React from 'react';
Expand Down Expand Up @@ -59,9 +59,8 @@ export const ChartSection = ({
}: Props) => {
const isDarkMode = useIsDarkMode();
const metrics = series.map((chartSeries) => chartSeries.metric);
const tooltipProps = {
headerFormatter: (tooltipValue: TooltipValue) =>
moment(tooltipValue.value).format('Y-MM-DD HH:mm:ss.SSS'),
const tooltipProps: TooltipProps = {
headerFormatter: ({ value }) => moment(value).format('Y-MM-DD HH:mm:ss.SSS'),
};

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { Axis, Chart, niceTimeFormatter, Position, Settings, TooltipValue } from '@elastic/charts';
import { Axis, Chart, niceTimeFormatter, Position, Settings, TooltipProps } from '@elastic/charts';
import {
EuiDescriptionListDescription,
EuiDescriptionListTitle,
Expand Down Expand Up @@ -95,9 +95,8 @@ const ProcessChart = ({ timeseries, color, label }: ProcessChartProps) => {

const yAxisFormatter = createFormatter('percent');

const tooltipProps = {
headerFormatter: (tooltipValue: TooltipValue) =>
moment(tooltipValue.value).format('Y-MM-DD HH:mm:ss.SSS'),
const tooltipProps: TooltipProps = {
headerFormatter: ({ value }) => moment(value).format('Y-MM-DD HH:mm:ss.SSS'),
};

const dataDomain = calculateDomain(timeseries, [chartMetric], false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ import {
Chart,
Settings,
Position,
TooltipValue,
niceTimeFormatter,
ElementClickListener,
RectAnnotation,
RectAnnotationDatum,
XYChartElementEvent,
TooltipProps,
} from '@elastic/charts';
import { EuiFlexItem } from '@elastic/eui';
import { EuiFlexGroup } from '@elastic/eui';
Expand Down Expand Up @@ -123,9 +123,8 @@ export const Timeline: React.FC<Props> = ({ interval, yAxisFormatter, isVisible
}, [timeseries]);

const isDarkMode = useIsDarkMode();
const tooltipProps = {
headerFormatter: (tooltipValue: TooltipValue) =>
moment(tooltipValue.value).format('Y-MM-DD HH:mm:ss.SSS'),
const tooltipProps: TooltipProps = {
headerFormatter: ({ value }) => moment(value).format('Y-MM-DD HH:mm:ss.SSS'),
};

const dataDomain = timeseries ? calculateDomain(timeseries, [chartMetric], false) : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import {
niceTimeFormatter,
Position,
Settings,
TooltipValue,
BrushEndListener,
TooltipProps,
} from '@elastic/charts';
import { EuiPageContentBody_Deprecated as EuiPageContentBody } from '@elastic/eui';
import { useIsDarkMode } from '../../../../hooks/use_is_dark_mode';
Expand Down Expand Up @@ -75,9 +75,9 @@ export const ChartSectionVis = ({
},
[onChangeRangeTime, isLiveStreaming, stopLiveStreaming]
);
const tooltipProps = {
headerFormatter: useCallback(
(data: TooltipValue) => moment(data.value).format(dateFormat || 'Y-MM-DD HH:mm:ss.SSS'),
const tooltipProps: TooltipProps = {
headerFormatter: useCallback<NonNullable<TooltipProps['headerFormatter']>>(
({ value }) => moment(value).format(dateFormat || 'Y-MM-DD HH:mm:ss.SSS'),
[dateFormat]
),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
niceTimeFormatter,
Position,
Settings,
TooltipValue,
TooltipProps,
} from '@elastic/charts';
import { EuiFlexGroup, EuiFlexItem, EuiTitle, EuiToolTip } from '@elastic/eui';
import { euiStyled } from '@kbn/kibana-react-plugin/common';
Expand Down Expand Up @@ -82,9 +82,9 @@ export const MetricsExplorerChart = ({
? niceTimeFormatter([firstRow.timestamp, lastRow.timestamp])
: (value: number) => `${value}`;
}, [series.rows]);
const tooltipProps = {
headerFormatter: useCallback(
(data: TooltipValue) => moment(data.value).format(dateFormat || 'Y-MM-DD HH:mm:ss.SSS'),
const tooltipProps: TooltipProps = {
headerFormatter: useCallback<NonNullable<TooltipProps['headerFormatter']>>(
({ value }) => moment(value).format(dateFormat || 'Y-MM-DD HH:mm:ss.SSS'),
[dateFormat]
),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
BrushEndListener,
Chart,
ElementClickListener,
CustomTooltip,
Heatmap,
HeatmapBrushEvent,
HeatmapElementEvent,
Expand Down Expand Up @@ -80,7 +81,7 @@ export function isViewBySwimLaneData(arg: any): arg is ViewBySwimLaneData {
* Provides a custom tooltip for the anomaly swim lane chart.
*/
const SwimLaneTooltip =
(fieldName?: string): FC<{ values: TooltipValue[] }> =>
(fieldName?: string): CustomTooltip =>
({ values }) => {
const tooltipData: TooltipValue[] = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
Tooltip,
XYChartElementEvent,
TooltipContainer,
TooltipInfo,
CustomTooltip,
} from '@elastic/charts';
import { EuiPanel } from '@elastic/eui';
import { keyBy } from 'lodash';
Expand Down Expand Up @@ -57,7 +57,7 @@ export function StackedBarChart({

const { chartsBaseTheme, chartsTheme } = useProfilingChartsTheme();

function CustomTooltipWithSubChart(props: TooltipInfo) {
const CustomTooltipWithSubChart: CustomTooltip = () => {
if (!highlightedSample) {
return null;
}
Expand Down Expand Up @@ -90,7 +90,7 @@ export function StackedBarChart({
</EuiPanel>
</TooltipContainer>
);
}
};

return (
<Chart size={{ height }}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import React, { useMemo, useCallback } from 'react';
import type { TooltipValue } from '@elastic/charts';
import type { TooltipHeaderFormatter } from '@elastic/charts';
import {
Chart,
LineSeries,
Expand Down Expand Up @@ -80,8 +80,8 @@ const RiskScoreOverTimeComponent: React.FC<RiskScoreOverTimeProps> = ({
const timeZone = useTimeZone();

const dataTimeFormatter = useMemo(() => histogramDateTimeFormatter([from, to]), [from, to]);
const headerFormatter = useCallback(
(tooltip: TooltipValue) => <PreferenceFormattedDate value={tooltip.value} />,
const headerFormatter = useCallback<TooltipHeaderFormatter>(
({ value }) => <PreferenceFormattedDate value={value} />,
[]
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import {
ScaleType,
Settings,
TickFormatter,
TooltipInfo,
TooltipContainer,
CustomTooltip,
} from '@elastic/charts';
import { useEuiTheme } from '@elastic/eui';
import { useChartTheme } from '../../../../../../hooks/use_chart_theme';
Expand All @@ -36,7 +36,7 @@ const getChartHeight = (data: WaterfallData): number => {
return noOfXBars * BAR_HEIGHT;
};

const Tooltip = (tooltipInfo: TooltipInfo) => {
const Tooltip: CustomTooltip = (tooltipInfo) => {
const { data, sidebarItems } = useWaterfallContext();
return useMemo(() => {
const sidebarItem = sidebarItems?.find((item) => item.index === tooltipInfo.header?.value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import {
ScaleType,
Settings,
TickFormatter,
TooltipInfo,
TooltipContainer,
CustomTooltip,
} from '@elastic/charts';
import { BAR_HEIGHT } from './constants';
import { useChartTheme } from '../../../../../hooks/use_chart_theme';
Expand All @@ -34,7 +34,7 @@ const getChartHeight = (data: WaterfallData): number => {
return noOfXBars * BAR_HEIGHT;
};

const Tooltip = (tooltipInfo: TooltipInfo) => {
const Tooltip: CustomTooltip = (tooltipInfo) => {
const { data, sidebarItems } = useWaterfallContext();
return useMemo(() => {
const sidebarItem = sidebarItems?.find((item) => item.index === tooltipInfo.header?.value);
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1469,10 +1469,10 @@
dependencies:
object-hash "^1.3.0"

"@elastic/charts@55.0.0":
version "55.0.0"
resolved "https://registry.yarnpkg.com/@elastic/charts/-/charts-55.0.0.tgz#df9a4e9b0a84a613f103011d99f120cb528c4dc9"
integrity sha512-a4UIieTi04CPHxfwztDe36xoPFkp+I4tRPXWXobv/aG/zTd4AwruRyL981RiV2Tv8Mrc5jpCJFgfadNoPrL3pg==
"@elastic/charts@57.0.1":
version "57.0.1"
resolved "https://registry.yarnpkg.com/@elastic/charts/-/charts-57.0.1.tgz#c48209f11be8984310dd366f8ead6d8c04720402"
integrity sha512-+wVSMjZIk5oAfslRKpcmpVGgT4qbf3IGtp4rQEUVTIMAJiYv6m5optVmQvg+n/JkR9/k/SVobtW1WylIKzQi9w==
dependencies:
"@popperjs/core" "^2.4.0"
bezier-easing "^2.1.0"
Expand Down