Skip to content

Commit

Permalink
[CSM Dashboard] Remove points from line chart (elastic#77617)
Browse files Browse the repository at this point in the history
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
shahzad31 and elasticmachine committed Sep 18, 2020
1 parent a0b9342 commit 6f18f90
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ export function BreakdownFilter({
const onOptionChange = (value: string) => {
if (value === NO_BREAKDOWN) {
onBreakdownChange(null);
} else {
onBreakdownChange(items.find(({ fieldName }) => fieldName === value)!);
}
onBreakdownChange(items.find(({ fieldName }) => fieldName === value)!);
};

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
TooltipValueFormatter,
DARK_THEME,
LIGHT_THEME,
Fit,
} from '@elastic/charts';
import {
EUI_CHARTS_THEME_DARK,
Expand Down Expand Up @@ -115,12 +116,14 @@ export function PageLoadDistChart({
tickFormat={(d) => numeral(d).format('0.0') + '%'}
/>
<LineSeries
fit={Fit.Linear}
id={'PagesPercentage'}
name={I18LABELS.overall}
xScaleType={ScaleType.Linear}
yScaleType={ScaleType.Linear}
data={data?.pageLoadDistribution ?? []}
curve={CurveType.CURVE_CATMULL_ROM}
lineSeriesStyle={{ point: { visible: false } }}
/>
{breakdown && (
<BreakdownSeries
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { CurveType, LineSeries, ScaleType } from '@elastic/charts';
import { CurveType, Fit, LineSeries, ScaleType } from '@elastic/charts';
import React, { useEffect } from 'react';
import { PercentileRange } from './index';
import { useBreakdowns } from './use_breakdowns';
Expand Down Expand Up @@ -41,8 +41,10 @@ export function BreakdownSeries({
name={name}
xScaleType={ScaleType.Linear}
yScaleType={ScaleType.Linear}
curve={CurveType.CURVE_CATMULL_ROM}
data={seriesData ?? []}
curve={CurveType.CURVE_NATURAL}
lineSeriesStyle={{ point: { visible: false } }}
fit={Fit.Linear}
/>
))}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,27 @@ import {

export const MICRO_TO_SEC = 1000000;

const NUMBER_OF_PLD_STEPS = 100;

export function microToSec(val: number) {
return Math.round((val / MICRO_TO_SEC + Number.EPSILON) * 100) / 100;
}

export const getPLDChartSteps = ({
maxDuration,
minDuration,
}: {
maxDuration: number;
minDuration: number;
}) => {
const stepValue = (maxDuration - minDuration) / NUMBER_OF_PLD_STEPS;
const stepValues = [];
for (let i = 1; i < NUMBER_OF_PLD_STEPS + 1; i++) {
stepValues.push((stepValue * i + minDuration).toFixed(2));
}
return stepValues;
};

export async function getPageLoadDistribution({
setup,
minPercentile,
Expand Down Expand Up @@ -105,11 +122,7 @@ const getPercentilesDistribution = async ({
minDuration: number;
maxDuration: number;
}) => {
const stepValue = (maxDuration - minDuration) / 100;
const stepValues = [];
for (let i = 1; i < 101; i++) {
stepValues.push((stepValue * i + minDuration).toFixed(2));
}
const stepValues = getPLDChartSteps({ maxDuration, minDuration });

const projection = getRumPageLoadTransactionsProjection({
setup,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ import {
USER_AGENT_OS,
TRANSACTION_DURATION,
} from '../../../common/elasticsearch_fieldnames';
import { MICRO_TO_SEC, microToSec } from './get_page_load_distribution';
import {
getPLDChartSteps,
MICRO_TO_SEC,
microToSec,
} from './get_page_load_distribution';

export const getBreakdownField = (breakdown: string) => {
switch (breakdown) {
Expand Down Expand Up @@ -47,13 +51,10 @@ export const getPageLoadDistBreakdown = async ({
breakdown: string;
}) => {
// convert secs to micros
const stepValue =
(maxDuration * MICRO_TO_SEC - minDuration * MICRO_TO_SEC) / 50;
const stepValues = [];

for (let i = 1; i < 51; i++) {
stepValues.push((stepValue * i + minDuration).toFixed(2));
}
const stepValues = getPLDChartSteps({
minDuration: minDuration * MICRO_TO_SEC,
maxDuration: maxDuration * MICRO_TO_SEC,
});

const projection = getRumPageLoadTransactionsProjection({
setup,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export async function getWebCoreVitals({

// Divide by 1000 to convert ms into seconds
return {
cls: String(cls?.values['50.0'] || 0),
cls: String(cls?.values['50.0']?.toFixed(2) || 0),
fid: ((fid?.values['50.0'] || 0) / 1000).toFixed(2),
lcp: ((lcp?.values['50.0'] || 0) / 1000).toFixed(2),
tbt: ((tbt?.values['50.0'] || 0) / 1000).toFixed(2),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default function rumServicesApiTests({ getService }: FtrProviderContext)

expectSnapshot(response.body).toMatchInline(`
Object {
"cls": "0",
"cls": "0.00",
"clsRanks": Array [
100,
0,
Expand Down

0 comments on commit 6f18f90

Please sign in to comment.