-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
89f5f61
commit defa0f9
Showing
10 changed files
with
586 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
181 changes: 181 additions & 0 deletions
181
.../components/shared/charts/instances_latency_distribution_chart/custom_tooltip.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { TooltipInfo } from '@elastic/charts'; | ||
import React, { ComponentType } from 'react'; | ||
import { EuiThemeProvider } from '../../../../../../../../src/plugins/kibana_react/common'; | ||
import { getDurationFormatter } from '../../../../../common/utils/formatters'; | ||
import { PrimaryStatsServiceInstanceItem } from '../../../app/service_overview/service_overview_instances_chart_and_table'; | ||
import { CustomTooltip } from './custom_tooltip'; | ||
|
||
function getLatencyFormatter(props: TooltipInfo) { | ||
const maxLatency = Math.max( | ||
...props.values.map((value) => { | ||
const datum = (value.datum as unknown) as PrimaryStatsServiceInstanceItem; | ||
return datum.latency ?? 0; | ||
}) | ||
); | ||
return getDurationFormatter(maxLatency); | ||
} | ||
|
||
export default { | ||
title: 'shared/charts/InstancesLatencyDistributionChart/CustomTooltip', | ||
component: CustomTooltip, | ||
decorators: [ | ||
(Story: ComponentType) => ( | ||
<EuiThemeProvider> | ||
<Story /> | ||
</EuiThemeProvider> | ||
), | ||
], | ||
}; | ||
|
||
export function Example(props: TooltipInfo) { | ||
return ( | ||
<CustomTooltip {...props} latencyFormatter={getLatencyFormatter(props)} /> | ||
); | ||
} | ||
Example.args = { | ||
header: { | ||
seriesIdentifier: { | ||
key: | ||
'groupId{__global__}spec{Instances}yAccessor{(index:0)}splitAccessors{}', | ||
specId: 'Instances', | ||
yAccessor: '(index:0)', | ||
splitAccessors: {}, | ||
seriesKeys: ['(index:0)'], | ||
}, | ||
valueAccessor: 'y1', | ||
label: 'Instances', | ||
value: 9.473837632998105, | ||
formattedValue: '9.473837632998105', | ||
markValue: null, | ||
color: '#6092c0', | ||
isHighlighted: false, | ||
isVisible: true, | ||
datum: { | ||
serviceNodeName: | ||
'2f3221afa3f00d3bc07069d69efd5bd4c1607be6155a204551c8fe2e2b5dd750', | ||
errorRate: 0.03496503496503497, | ||
latency: 1057231.4125874126, | ||
throughput: 9.473837632998105, | ||
cpuUsage: 0.000033333333333333335, | ||
memoryUsage: 0.18701022939403547, | ||
}, | ||
}, | ||
values: [ | ||
{ | ||
seriesIdentifier: { | ||
key: | ||
'groupId{__global__}spec{Instances}yAccessor{(index:0)}splitAccessors{}', | ||
specId: 'Instances', | ||
}, | ||
valueAccessor: 'y1', | ||
label: 'Instances', | ||
value: 1057231.4125874126, | ||
formattedValue: '1057231.4125874126', | ||
markValue: null, | ||
color: '#6092c0', | ||
isHighlighted: true, | ||
isVisible: true, | ||
datum: { | ||
serviceNodeName: | ||
'2f3221afa3f00d3bc07069d69efd5bd4c1607be6155a204551c8fe2e2b5dd750', | ||
errorRate: 0.03496503496503497, | ||
latency: 1057231.4125874126, | ||
throughput: 9.473837632998105, | ||
cpuUsage: 0.000033333333333333335, | ||
memoryUsage: 0.18701022939403547, | ||
}, | ||
}, | ||
], | ||
} as TooltipInfo; | ||
|
||
export function MultipleInstances(props: TooltipInfo) { | ||
return ( | ||
<CustomTooltip {...props} latencyFormatter={getLatencyFormatter(props)} /> | ||
); | ||
} | ||
MultipleInstances.args = { | ||
header: { | ||
seriesIdentifier: { | ||
key: | ||
'groupId{__global__}spec{Instances}yAccessor{(index:0)}splitAccessors{}', | ||
specId: 'Instances', | ||
yAccessor: '(index:0)', | ||
splitAccessors: {}, | ||
seriesKeys: ['(index:0)'], | ||
}, | ||
valueAccessor: 'y1', | ||
label: 'Instances', | ||
value: 9.606338858634443, | ||
formattedValue: '9.606338858634443', | ||
markValue: null, | ||
color: '#6092c0', | ||
isHighlighted: false, | ||
isVisible: true, | ||
datum: { | ||
serviceNodeName: | ||
'3b50ad269c45be69088905c4b355cc75ab94aaac1b35432bb752050438f4216f', | ||
errorRate: 0.006896551724137931, | ||
latency: 56465.53793103448, | ||
throughput: 9.606338858634443, | ||
cpuUsage: 0.0001, | ||
memoryUsage: 0.1872131360014741, | ||
}, | ||
}, | ||
values: [ | ||
{ | ||
seriesIdentifier: { | ||
key: | ||
'groupId{__global__}spec{Instances}yAccessor{(index:0)}splitAccessors{}', | ||
specId: 'Instances', | ||
}, | ||
valueAccessor: 'y1', | ||
label: 'Instances', | ||
value: 56465.53793103448, | ||
formattedValue: '56465.53793103448', | ||
markValue: null, | ||
color: '#6092c0', | ||
isHighlighted: true, | ||
isVisible: true, | ||
datum: { | ||
serviceNodeName: | ||
'3b50ad269c45be69088905c4b355cc75ab94aaac1b35432bb752050438f4216f', | ||
errorRate: 0.006896551724137931, | ||
latency: 56465.53793103448, | ||
throughput: 9.606338858634443, | ||
cpuUsage: 0.0001, | ||
memoryUsage: 0.1872131360014741, | ||
}, | ||
}, | ||
{ | ||
seriesIdentifier: { | ||
key: | ||
'groupId{__global__}spec{Instances}yAccessor{(index:0)}splitAccessors{}', | ||
specId: 'Instances', | ||
}, | ||
valueAccessor: 'y1', | ||
label: 'Instances', | ||
value: 56465.53793103448, | ||
formattedValue: '56465.53793103448', | ||
markValue: null, | ||
color: '#6092c0', | ||
isHighlighted: true, | ||
isVisible: true, | ||
datum: { | ||
serviceNodeName: | ||
'3b50ad269c45be69088905c4b355cc75ab94aaac1b35432bb752050438f4216f (2)', | ||
errorRate: 0.006896551724137931, | ||
latency: 56465.53793103448, | ||
throughput: 9.606338858634443, | ||
cpuUsage: 0.0001, | ||
memoryUsage: 0.1872131360014741, | ||
}, | ||
}, | ||
], | ||
} as TooltipInfo; |
Oops, something went wrong.