Skip to content

Commit 5be36b7

Browse files
[CSM Dashboard] Remove points from line chart (#77617)
Co-authored-by: Elastic Machine <[email protected]>
1 parent d1a6e89 commit 5be36b7

File tree

7 files changed

+38
-18
lines changed

7 files changed

+38
-18
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,9 @@ export function BreakdownFilter({
7575
const onOptionChange = (value: string) => {
7676
if (value === NO_BREAKDOWN) {
7777
onBreakdownChange(null);
78+
} else {
79+
onBreakdownChange(items.find(({ fieldName }) => fieldName === value)!);
7880
}
79-
onBreakdownChange(items.find(({ fieldName }) => fieldName === value)!);
8081
};
8182

8283
return (

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
TooltipValueFormatter,
1919
DARK_THEME,
2020
LIGHT_THEME,
21+
Fit,
2122
} from '@elastic/charts';
2223
import {
2324
EUI_CHARTS_THEME_DARK,
@@ -115,12 +116,14 @@ export function PageLoadDistChart({
115116
tickFormat={(d) => numeral(d).format('0.0') + '%'}
116117
/>
117118
<LineSeries
119+
fit={Fit.Linear}
118120
id={'PagesPercentage'}
119121
name={I18LABELS.overall}
120122
xScaleType={ScaleType.Linear}
121123
yScaleType={ScaleType.Linear}
122124
data={data?.pageLoadDistribution ?? []}
123125
curve={CurveType.CURVE_CATMULL_ROM}
126+
lineSeriesStyle={{ point: { visible: false } }}
124127
/>
125128
{breakdown && (
126129
<BreakdownSeries

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7-
import { CurveType, LineSeries, ScaleType } from '@elastic/charts';
7+
import { CurveType, Fit, LineSeries, ScaleType } from '@elastic/charts';
88
import React, { useEffect } from 'react';
99
import { PercentileRange } from './index';
1010
import { useBreakdowns } from './use_breakdowns';
@@ -41,8 +41,10 @@ export function BreakdownSeries({
4141
name={name}
4242
xScaleType={ScaleType.Linear}
4343
yScaleType={ScaleType.Linear}
44+
curve={CurveType.CURVE_CATMULL_ROM}
4445
data={seriesData ?? []}
45-
curve={CurveType.CURVE_NATURAL}
46+
lineSeriesStyle={{ point: { visible: false } }}
47+
fit={Fit.Linear}
4648
/>
4749
))}
4850
</>

x-pack/plugins/apm/server/lib/rum_client/get_page_load_distribution.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,27 @@ import {
1515

1616
export const MICRO_TO_SEC = 1000000;
1717

18+
const NUMBER_OF_PLD_STEPS = 100;
19+
1820
export function microToSec(val: number) {
1921
return Math.round((val / MICRO_TO_SEC + Number.EPSILON) * 100) / 100;
2022
}
2123

24+
export const getPLDChartSteps = ({
25+
maxDuration,
26+
minDuration,
27+
}: {
28+
maxDuration: number;
29+
minDuration: number;
30+
}) => {
31+
const stepValue = (maxDuration - minDuration) / NUMBER_OF_PLD_STEPS;
32+
const stepValues = [];
33+
for (let i = 1; i < NUMBER_OF_PLD_STEPS + 1; i++) {
34+
stepValues.push((stepValue * i + minDuration).toFixed(2));
35+
}
36+
return stepValues;
37+
};
38+
2239
export async function getPageLoadDistribution({
2340
setup,
2441
minPercentile,
@@ -105,11 +122,7 @@ const getPercentilesDistribution = async ({
105122
minDuration: number;
106123
maxDuration: number;
107124
}) => {
108-
const stepValue = (maxDuration - minDuration) / 100;
109-
const stepValues = [];
110-
for (let i = 1; i < 101; i++) {
111-
stepValues.push((stepValue * i + minDuration).toFixed(2));
112-
}
125+
const stepValues = getPLDChartSteps({ maxDuration, minDuration });
113126

114127
const projection = getRumPageLoadTransactionsProjection({
115128
setup,

x-pack/plugins/apm/server/lib/rum_client/get_pl_dist_breakdown.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ import {
1919
USER_AGENT_OS,
2020
TRANSACTION_DURATION,
2121
} from '../../../common/elasticsearch_fieldnames';
22-
import { MICRO_TO_SEC, microToSec } from './get_page_load_distribution';
22+
import {
23+
getPLDChartSteps,
24+
MICRO_TO_SEC,
25+
microToSec,
26+
} from './get_page_load_distribution';
2327

2428
export const getBreakdownField = (breakdown: string) => {
2529
switch (breakdown) {
@@ -47,13 +51,10 @@ export const getPageLoadDistBreakdown = async ({
4751
breakdown: string;
4852
}) => {
4953
// convert secs to micros
50-
const stepValue =
51-
(maxDuration * MICRO_TO_SEC - minDuration * MICRO_TO_SEC) / 50;
52-
const stepValues = [];
53-
54-
for (let i = 1; i < 51; i++) {
55-
stepValues.push((stepValue * i + minDuration).toFixed(2));
56-
}
54+
const stepValues = getPLDChartSteps({
55+
minDuration: minDuration * MICRO_TO_SEC,
56+
maxDuration: maxDuration * MICRO_TO_SEC,
57+
});
5758

5859
const projection = getRumPageLoadTransactionsProjection({
5960
setup,

x-pack/plugins/apm/server/lib/rum_client/get_web_core_vitals.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export async function getWebCoreVitals({
124124

125125
// Divide by 1000 to convert ms into seconds
126126
return {
127-
cls: String(cls?.values['50.0'] || 0),
127+
cls: String(cls?.values['50.0']?.toFixed(2) || 0),
128128
fid: ((fid?.values['50.0'] || 0) / 1000).toFixed(2),
129129
lcp: ((lcp?.values['50.0'] || 0) / 1000).toFixed(2),
130130
tbt: ((tbt?.values['50.0'] || 0) / 1000).toFixed(2),

x-pack/test/apm_api_integration/trial/tests/csm/web_core_vitals.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export default function rumServicesApiTests({ getService }: FtrProviderContext)
5252

5353
expectSnapshot(response.body).toMatchInline(`
5454
Object {
55-
"cls": "0",
55+
"cls": "0.00",
5656
"clsRanks": Array [
5757
100,
5858
0,

0 commit comments

Comments
 (0)