Skip to content

Commit f81ff08

Browse files
authored
[7.x] [RUM Dashboard] Visitor breakdown usability (#76834) (#77166)
1 parent 368413d commit f81ff08

File tree

6 files changed

+87
-83
lines changed

6 files changed

+87
-83
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,14 @@ interface Props {
2626
* aria-label for accessibility
2727
*/
2828
'aria-label'?: string;
29+
30+
maxWidth?: string;
2931
}
3032

3133
export function ChartWrapper({
3234
loading = false,
3335
height = '100%',
36+
maxWidth,
3437
children,
3538
...rest
3639
}: Props) {
@@ -43,6 +46,7 @@ export function ChartWrapper({
4346
height,
4447
opacity,
4548
transition: 'opacity 0.2s',
49+
...(maxWidth ? { maxWidth } : {}),
4650
}}
4751
{...(rest as HTMLAttributes<HTMLDivElement>)}
4852
>
@@ -52,7 +56,12 @@ export function ChartWrapper({
5256
<EuiFlexGroup
5357
justifyContent="spaceAround"
5458
alignItems="center"
55-
style={{ height, marginTop: `-${height}`, marginBottom: 0 }}
59+
style={{
60+
height,
61+
marginTop: `-${height}`,
62+
marginBottom: 0,
63+
...(maxWidth ? { maxWidth } : {}),
64+
}}
5665
>
5766
<EuiFlexItem grow={false}>
5867
<EuiLoadingChart size="xl" />

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

Lines changed: 43 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,18 @@ import {
1414
PartitionLayout,
1515
Settings,
1616
} from '@elastic/charts';
17-
import euiLightVars from '@elastic/eui/dist/eui_theme_light.json';
17+
import styled from 'styled-components';
1818
import {
1919
EUI_CHARTS_THEME_DARK,
2020
EUI_CHARTS_THEME_LIGHT,
2121
} from '@elastic/eui/dist/eui_charts_theme';
2222
import { useUiSetting$ } from '../../../../../../../../src/plugins/kibana_react/public';
2323
import { ChartWrapper } from '../ChartWrapper';
2424

25+
const StyleChart = styled.div`
26+
height: 100%;
27+
`;
28+
2529
interface Props {
2630
options?: Array<{
2731
count: number;
@@ -32,65 +36,47 @@ interface Props {
3236
export function VisitorBreakdownChart({ options }: Props) {
3337
const [darkMode] = useUiSetting$<boolean>('theme:darkMode');
3438

39+
const euiChartTheme = darkMode
40+
? EUI_CHARTS_THEME_DARK
41+
: EUI_CHARTS_THEME_LIGHT;
42+
3543
return (
36-
<ChartWrapper loading={false} height="220px">
37-
<Chart>
38-
<Settings
39-
baseTheme={darkMode ? DARK_THEME : LIGHT_THEME}
40-
theme={
41-
darkMode
42-
? EUI_CHARTS_THEME_DARK.theme
43-
: EUI_CHARTS_THEME_LIGHT.theme
44-
}
45-
/>
46-
<Partition
47-
id="spec_1"
48-
data={options || []}
49-
valueAccessor={(d: Datum) => d.count as number}
50-
valueGetter="percent"
51-
percentFormatter={(d: number) =>
52-
`${Math.round((d + Number.EPSILON) * 100) / 100}%`
53-
}
54-
layers={[
55-
{
56-
groupByRollup: (d: Datum) => d.name,
57-
nodeLabel: (d: Datum) => d,
58-
// fillLabel: { textInvertible: true },
59-
shape: {
60-
fillColor: (d) => {
61-
const clrs = [
62-
euiLightVars.euiColorVis1_behindText,
63-
euiLightVars.euiColorVis0_behindText,
64-
euiLightVars.euiColorVis2_behindText,
65-
euiLightVars.euiColorVis3_behindText,
66-
euiLightVars.euiColorVis4_behindText,
67-
euiLightVars.euiColorVis5_behindText,
68-
euiLightVars.euiColorVis6_behindText,
69-
euiLightVars.euiColorVis7_behindText,
70-
euiLightVars.euiColorVis8_behindText,
71-
euiLightVars.euiColorVis9_behindText,
72-
];
73-
return clrs[d.sortIndex];
44+
<ChartWrapper loading={false} height="230px" maxWidth="430px">
45+
<StyleChart>
46+
<Chart>
47+
<Settings
48+
showLegend
49+
baseTheme={darkMode ? DARK_THEME : LIGHT_THEME}
50+
theme={euiChartTheme.theme}
51+
/>
52+
<Partition
53+
id="spec_1"
54+
data={options || []}
55+
valueAccessor={(d: Datum) => d.count as number}
56+
valueGetter="percent"
57+
percentFormatter={(d: number) =>
58+
`${Math.round((d + Number.EPSILON) * 100) / 100}%`
59+
}
60+
layers={[
61+
{
62+
groupByRollup: (d: Datum) => d.name,
63+
shape: {
64+
fillColor: (d) =>
65+
euiChartTheme.theme.colors?.vizColors?.[d.sortIndex]!,
7466
},
7567
},
76-
},
77-
]}
78-
config={{
79-
partitionLayout: PartitionLayout.sunburst,
80-
linkLabel: {
81-
maxCount: 32,
82-
fontSize: 14,
83-
},
84-
fontFamily: 'Arial',
85-
margin: { top: 0, bottom: 0, left: 0, right: 0 },
86-
minFontSize: 1,
87-
idealFontSizeJump: 1.1,
88-
outerSizeRatio: 0.9, // - 0.5 * Math.random(),
89-
emptySizeRatio: 0,
90-
circlePadding: 4,
91-
}}
92-
/>
93-
</Chart>
68+
]}
69+
config={{
70+
partitionLayout: PartitionLayout.sunburst,
71+
linkLabel: { maximumSection: Infinity, maxCount: 0 },
72+
margin: { top: 0, bottom: 0, left: 0, right: 0 },
73+
outerSizeRatio: 1, // - 0.5 * Math.random(),
74+
circlePadding: 4,
75+
clockwiseSectors: false,
76+
}}
77+
/>
78+
</Chart>
79+
</StyleChart>
9480
</ChartWrapper>
9581
);
9682
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export function ClientMetrics() {
4545
<ClFlexGroup responsive={false}>
4646
<EuiFlexItem grow={false} style={STAT_STYLE}>
4747
<EuiStat
48-
titleSize="s"
48+
titleSize="l"
4949
title={
5050
(((data?.backEnd?.value ?? 0) * 1000).toFixed(0) ?? '-') + ' ms'
5151
}
@@ -55,15 +55,15 @@ export function ClientMetrics() {
5555
</EuiFlexItem>
5656
<EuiFlexItem grow={false} style={STAT_STYLE}>
5757
<EuiStat
58-
titleSize="s"
58+
titleSize="l"
5959
title={((data?.frontEnd?.value ?? 0)?.toFixed(2) ?? '-') + ' s'}
6060
description={I18LABELS.frontEnd}
6161
isLoading={status !== 'success'}
6262
/>
6363
</EuiFlexItem>
6464
<EuiFlexItem grow={false} style={STAT_STYLE}>
6565
<EuiStat
66-
titleSize="s"
66+
titleSize="l"
6767
title={
6868
<EuiToolTip content={data?.pageViews?.value}>
6969
<>{numeral(data?.pageViews?.value).format('0 a') ?? '-'}</>

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,18 @@ export function RumDashboard() {
4949
</EuiPanel>
5050
</EuiFlexItem>
5151
<EuiFlexItem>
52-
<EuiPanel>
53-
<EuiFlexGroup justifyContent="spaceBetween">
54-
<EuiFlexItem grow={3}>
52+
<EuiFlexGroup gutterSize="s" wrap>
53+
<EuiFlexItem style={{ flexBasis: 650 }}>
54+
<EuiPanel>
5555
<PageLoadDistribution />
56-
<EuiSpacer size="m" />
56+
</EuiPanel>
57+
</EuiFlexItem>
58+
<EuiFlexItem style={{ flexBasis: 650 }}>
59+
<EuiPanel>
5760
<PageViewsTrend />
58-
</EuiFlexItem>
59-
</EuiFlexGroup>
60-
</EuiPanel>
61+
</EuiPanel>
62+
</EuiFlexItem>
63+
</EuiFlexGroup>
6164
<EuiSpacer size="s" />
6265
<EuiPanel>
6366
<EuiFlexGroup justifyContent="spaceBetween">

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

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
*/
66

77
import React from 'react';
8-
import { EuiFlexGroup, EuiFlexItem, EuiTitle } from '@elastic/eui';
8+
import { EuiFlexGroup, EuiFlexItem, EuiTitle, EuiSpacer } from '@elastic/eui';
99
import { VisitorBreakdownChart } from '../Charts/VisitorBreakdownChart';
10-
import { VisitorBreakdownLabel } from '../translations';
10+
import { I18LABELS, VisitorBreakdownLabel } from '../translations';
1111
import { useFetcher } from '../../../../hooks/useFetcher';
1212
import { useUrlParams } from '../../../../hooks/useUrlParams';
1313

@@ -37,27 +37,24 @@ export function VisitorBreakdown() {
3737

3838
return (
3939
<>
40-
<EuiTitle size="xs">
40+
<EuiTitle size="s">
4141
<h3>{VisitorBreakdownLabel}</h3>
4242
</EuiTitle>
43+
<EuiSpacer size="s" />
4344
<EuiFlexGroup>
4445
<EuiFlexItem>
45-
<VisitorBreakdownChart options={data?.browsers} />
46-
<EuiTitle size="xs" className="eui-textCenter">
47-
<h4>Browser</h4>
48-
</EuiTitle>
49-
</EuiFlexItem>
50-
<EuiFlexItem>
51-
<VisitorBreakdownChart options={data?.os} />
52-
<EuiTitle size="xs" className="eui-textCenter">
53-
<h4>Operating System</h4>
46+
<EuiTitle size="xs">
47+
<h4>{I18LABELS.browser}</h4>
5448
</EuiTitle>
49+
<EuiSpacer size="s" />
50+
<VisitorBreakdownChart options={data?.browsers} />
5551
</EuiFlexItem>
5652
<EuiFlexItem>
57-
<VisitorBreakdownChart options={data?.devices} />
58-
<EuiTitle size="xs" className="eui-textCenter">
59-
<h4>Device</h4>
53+
<EuiTitle size="xs">
54+
<h4>{I18LABELS.operatingSystem}</h4>
6055
</EuiTitle>
56+
<EuiSpacer size="s" />
57+
<VisitorBreakdownChart options={data?.os} />
6158
</EuiFlexItem>
6259
</EuiFlexGroup>
6360
</>

x-pack/plugins/apm/public/components/app/RumDashboard/translations.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,15 @@ export const I18LABELS = {
5555
coreWebVitals: i18n.translate('xpack.apm.rum.filterGroup.coreWebVitals', {
5656
defaultMessage: 'Core web vitals',
5757
}),
58+
browser: i18n.translate('xpack.apm.rum.visitorBreakdown.browser', {
59+
defaultMessage: 'Browser',
60+
}),
61+
operatingSystem: i18n.translate(
62+
'xpack.apm.rum.visitorBreakdown.operatingSystem',
63+
{
64+
defaultMessage: 'Operating system',
65+
}
66+
),
5867
};
5968

6069
export const VisitorBreakdownLabel = i18n.translate(

0 commit comments

Comments
 (0)