Skip to content

Commit 07ebb81

Browse files
[UX] Improve page-load axis (#78392)
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
1 parent 29da045 commit 07ebb81

File tree

15 files changed

+357
-74
lines changed

15 files changed

+357
-74
lines changed

x-pack/plugins/apm/e2e/cypress/support/step_definitions/csm/breakdown_filter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Then(`breakdown series should appear in chart`, () => {
3636

3737
cy.get('div.echLegendItem__label', DEFAULT_TIMEOUT).should(
3838
'have.text',
39-
'ChromeChrome Mobile WebViewSafariFirefoxMobile SafariChrome MobileChrome Mobile iOSOverall'
39+
'OverallChromeChrome Mobile WebViewSafariFirefoxMobile SafariChrome MobileChrome Mobile iOS'
4040
);
4141
});
4242
});

x-pack/plugins/apm/e2e/cypress/support/step_definitions/csm/csm_dashboard.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Given(`a user browses the APM UI application for RUM Data`, () => {
2626
});
2727

2828
Then(`should have correct client metrics`, () => {
29-
const metrics = ['4 ms', '0.06 s', '55 '];
29+
const metrics = ['4 ms', '58 ms', '55'];
3030

3131
verifyClientMetrics(metrics, true);
3232
});

x-pack/plugins/apm/e2e/cypress/support/step_definitions/csm/csm_filters.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Then(/^it filters the client metrics "([^"]*)"$/, (filterName) => {
5656
cy.get('.euiStat__title-isLoading').should('not.be.visible');
5757

5858
const data =
59-
filterName === 'os' ? ['5 ms', '0.06 s', '8 '] : ['4 ms', '0.05 s', '28 '];
59+
filterName === 'os' ? ['5 ms', '64 ms', '8'] : ['4 ms', '55 ms', '28'];
6060

6161
verifyClientMetrics(data, true);
6262

x-pack/plugins/apm/e2e/cypress/support/step_definitions/csm/percentile_select.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ When('the user changes the selected percentile', () => {
1818
});
1919

2020
Then(`it displays client metric related to that percentile`, () => {
21-
const metrics = ['14 ms', '0.13 s', '55 '];
21+
const metrics = ['14 ms', '131 ms', '55'];
2222

2323
verifyClientMetrics(metrics, false);
2424

x-pack/plugins/apm/e2e/cypress/support/step_definitions/csm/service_name_filter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ When('the user changes the selected service name', () => {
1515
});
1616

1717
Then(`it displays relevant client metrics`, () => {
18-
const metrics = ['4 ms', '0.06 s', '55 '];
18+
const metrics = ['4 ms', '58 ms', '55'];
1919

2020
verifyClientMetrics(metrics, false);
2121
});

x-pack/plugins/apm/public/components/app/RumDashboard/Charts/PageLoadDistChart.tsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ export function PageLoadDistChart({
8888

8989
const [darkMode] = useUiSetting$<boolean>('theme:darkMode');
9090

91+
const euiChartTheme = darkMode
92+
? EUI_CHARTS_THEME_DARK
93+
: EUI_CHARTS_THEME_LIGHT;
94+
9195
return (
9296
<ChartWrapper
9397
loading={loading || breakdownLoading}
@@ -97,11 +101,7 @@ export function PageLoadDistChart({
97101
<PageLoadChart>
98102
<Settings
99103
baseTheme={darkMode ? DARK_THEME : LIGHT_THEME}
100-
theme={
101-
darkMode
102-
? EUI_CHARTS_THEME_DARK.theme
103-
: EUI_CHARTS_THEME_LIGHT.theme
104-
}
104+
theme={euiChartTheme.theme}
105105
onBrushEnd={onBrushEnd}
106106
tooltip={tooltipProps}
107107
showLegend
@@ -116,17 +116,23 @@ export function PageLoadDistChart({
116116
id="left"
117117
title={I18LABELS.percPageLoaded}
118118
position={Position.Left}
119-
tickFormat={(d) => numeral(d).format('0.0') + '%'}
119+
labelFormat={(d) => d + ' %'}
120120
/>
121121
<LineSeries
122+
sortIndex={0}
122123
fit={Fit.Linear}
123124
id={'PagesPercentage'}
124125
name={I18LABELS.overall}
125126
xScaleType={ScaleType.Linear}
126127
yScaleType={ScaleType.Linear}
127128
data={data?.pageLoadDistribution ?? []}
128129
curve={CurveType.CURVE_CATMULL_ROM}
129-
lineSeriesStyle={{ point: { visible: false } }}
130+
lineSeriesStyle={{
131+
point: { visible: false },
132+
line: { strokeWidth: 3 },
133+
}}
134+
color={euiChartTheme.theme.colors?.vizColors?.[1]}
135+
tickFormat={(d) => numeral(d).format('0.0') + ' %'}
130136
/>
131137
{breakdown && (
132138
<BreakdownSeries

x-pack/plugins/apm/public/components/app/RumDashboard/Charts/PageViewsChart.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ export function PageViewsChart({ data, loading }: Props) {
7171
});
7272
};
7373

74+
const hasBreakdowns = !!data?.topItems?.length;
75+
7476
const breakdownAccessors = data?.topItems?.length ? data?.topItems : ['y'];
7577

7678
const [darkMode] = useUiSetting$<boolean>('theme:darkMode');
@@ -83,17 +85,17 @@ export function PageViewsChart({ data, loading }: Props) {
8385
return yAccessor;
8486
};
8587

88+
const euiChartTheme = darkMode
89+
? EUI_CHARTS_THEME_DARK
90+
: EUI_CHARTS_THEME_LIGHT;
91+
8692
return (
8793
<ChartWrapper loading={loading} height="calc(100% - 72px)">
8894
{(!loading || data) && (
8995
<Chart>
9096
<Settings
9197
baseTheme={darkMode ? DARK_THEME : LIGHT_THEME}
92-
theme={
93-
darkMode
94-
? EUI_CHARTS_THEME_DARK.theme
95-
: EUI_CHARTS_THEME_LIGHT.theme
96-
}
98+
theme={euiChartTheme.theme}
9799
showLegend
98100
onBrushEnd={onBrushEnd}
99101
xDomain={{
@@ -122,6 +124,11 @@ export function PageViewsChart({ data, loading }: Props) {
122124
stackAccessors={['x']}
123125
data={data?.items ?? []}
124126
name={customSeriesNaming}
127+
color={
128+
!hasBreakdowns
129+
? euiChartTheme.theme.colors?.vizColors?.[1]
130+
: undefined
131+
}
125132
/>
126133
</Chart>
127134
)}

x-pack/plugins/apm/public/components/app/RumDashboard/ClientMetrics/index.tsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { EuiFlexGroup, EuiFlexItem, EuiStat, EuiToolTip } from '@elastic/eui';
1111
import { useFetcher } from '../../../../hooks/useFetcher';
1212
import { I18LABELS } from '../translations';
1313
import { useUxQuery } from '../hooks/useUxQuery';
14+
import { formatToSec } from '../UXMetrics/KeyUXMetrics';
1415
import { CsmSharedContext } from '../CsmSharedContext';
1516

1617
const ClFlexGroup = styled(EuiFlexGroup)`
@@ -49,22 +50,22 @@ export function ClientMetrics() {
4950

5051
const STAT_STYLE = { width: '240px' };
5152

53+
const pageViewsTotal = data?.pageViews?.value ?? 0;
54+
5255
return (
5356
<ClFlexGroup responsive={false}>
5457
<EuiFlexItem grow={false} style={STAT_STYLE}>
5558
<EuiStat
5659
titleSize="l"
57-
title={
58-
(((data?.backEnd?.value ?? 0) * 1000).toFixed(0) ?? '-') + ' ms'
59-
}
60+
title={formatToSec(data?.backEnd?.value ?? 0, 'ms')}
6061
description={I18LABELS.backEnd}
6162
isLoading={status !== 'success'}
6263
/>
6364
</EuiFlexItem>
6465
<EuiFlexItem grow={false} style={STAT_STYLE}>
6566
<EuiStat
6667
titleSize="l"
67-
title={((data?.frontEnd?.value ?? 0)?.toFixed(2) ?? '-') + ' s'}
68+
title={formatToSec(data?.frontEnd?.value ?? 0, 'ms')}
6869
description={I18LABELS.frontEnd}
6970
isLoading={status !== 'success'}
7071
/>
@@ -73,9 +74,13 @@ export function ClientMetrics() {
7374
<EuiStat
7475
titleSize="l"
7576
title={
76-
<EuiToolTip content={data?.pageViews?.value}>
77-
<>{numeral(data?.pageViews?.value).format('0 a') ?? '-'}</>
78-
</EuiToolTip>
77+
pageViewsTotal < 10000 ? (
78+
numeral(pageViewsTotal).format('0,0')
79+
) : (
80+
<EuiToolTip content={numeral(pageViewsTotal).format('0,0')}>
81+
<>{numeral(pageViewsTotal).format('0 a')}</>
82+
</EuiToolTip>
83+
)
7984
}
8085
description={I18LABELS.pageViews}
8186
isLoading={status !== 'success'}

x-pack/plugins/apm/public/components/app/RumDashboard/PageLoadDistribution/BreakdownSeries.tsx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@
66

77
import { CurveType, Fit, LineSeries, ScaleType } from '@elastic/charts';
88
import React, { useEffect } from 'react';
9+
import {
10+
EUI_CHARTS_THEME_DARK,
11+
EUI_CHARTS_THEME_LIGHT,
12+
} from '@elastic/eui/dist/eui_charts_theme';
913
import { PercentileRange } from './index';
1014
import { useBreakdowns } from './use_breakdowns';
15+
import { useUiSetting$ } from '../../../../../../../../src/plugins/kibana_react/public';
1116

1217
interface Props {
1318
field: string;
@@ -22,6 +27,12 @@ export function BreakdownSeries({
2227
percentileRange,
2328
onLoadingChange,
2429
}: Props) {
30+
const [darkMode] = useUiSetting$<boolean>('theme:darkMode');
31+
32+
const euiChartTheme = darkMode
33+
? EUI_CHARTS_THEME_DARK
34+
: EUI_CHARTS_THEME_LIGHT;
35+
2536
const { data, status } = useBreakdowns({
2637
field,
2738
value,
@@ -32,9 +43,11 @@ export function BreakdownSeries({
3243
onLoadingChange(status !== 'success');
3344
}, [status, onLoadingChange]);
3445

46+
// sort index 1 color vizColors1 is already used for overall,
47+
// so don't user that here
3548
return (
3649
<>
37-
{data?.map(({ data: seriesData, name }) => (
50+
{data?.map(({ data: seriesData, name }, sortIndex) => (
3851
<LineSeries
3952
id={`${field}-${value}-${name}`}
4053
key={`${field}-${value}-${name}`}
@@ -45,6 +58,11 @@ export function BreakdownSeries({
4558
data={seriesData ?? []}
4659
lineSeriesStyle={{ point: { visible: false } }}
4760
fit={Fit.Linear}
61+
color={
62+
euiChartTheme.theme.colors?.vizColors?.[
63+
sortIndex === 0 ? 0 : sortIndex + 1
64+
]
65+
}
4866
/>
4967
))}
5068
</>

x-pack/plugins/apm/public/components/app/RumDashboard/UXMetrics/KeyUXMetrics.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import React from 'react';
88
import { EuiFlexItem, EuiStat, EuiFlexGroup } from '@elastic/eui';
9+
import numeral from '@elastic/numeral';
910
import { UXMetrics } from './index';
1011
import {
1112
FCP_LABEL,
@@ -77,7 +78,7 @@ export function KeyUXMetrics({ data, loading }: Props) {
7778
<EuiFlexItem grow={false} style={STAT_STYLE}>
7879
<EuiStat
7980
titleSize="s"
80-
title={longTaskData?.noOfLongTasks ?? 0}
81+
title={numeral(longTaskData?.noOfLongTasks ?? 0).format('0,0')}
8182
description={NO_OF_LONG_TASK}
8283
isLoading={status !== 'success'}
8384
/>

0 commit comments

Comments
 (0)