metricChart.tsx 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  1. import {Fragment, useCallback} from 'react';
  2. import {type Theme, useTheme} from '@emotion/react';
  3. import styled from '@emotion/styled';
  4. import color from 'color';
  5. import type {LineSeriesOption} from 'echarts';
  6. import type {TopLevelFormatterParams} from 'echarts/types/src/component/tooltip/TooltipModel';
  7. import moment from 'moment-timezone';
  8. import Feature from 'sentry/components/acl/feature';
  9. import {OnDemandMetricAlert} from 'sentry/components/alerts/onDemandMetricAlert';
  10. import {Button} from 'sentry/components/button';
  11. import type {AreaChartProps, AreaChartSeries} from 'sentry/components/charts/areaChart';
  12. import {AreaChart} from 'sentry/components/charts/areaChart';
  13. import ChartZoom from 'sentry/components/charts/chartZoom';
  14. import MarkArea from 'sentry/components/charts/components/markArea';
  15. import MarkLine from 'sentry/components/charts/components/markLine';
  16. import {
  17. transformComparisonTimeseriesData,
  18. transformTimeseriesData,
  19. } from 'sentry/components/charts/eventsRequest';
  20. import LineSeries from 'sentry/components/charts/series/lineSeries';
  21. import {
  22. ChartControls,
  23. HeaderTitleLegend,
  24. InlineContainer,
  25. SectionHeading,
  26. SectionValue,
  27. } from 'sentry/components/charts/styles';
  28. import {isEmptySeries} from 'sentry/components/charts/utils';
  29. import CircleIndicator from 'sentry/components/circleIndicator';
  30. import {parseStatsPeriod} from 'sentry/components/organizations/pageFilters/parse';
  31. import Panel from 'sentry/components/panels/panel';
  32. import PanelBody from 'sentry/components/panels/panelBody';
  33. import Placeholder from 'sentry/components/placeholder';
  34. import {Tooltip} from 'sentry/components/tooltip';
  35. import {IconCheckmark, IconClock, IconFire, IconWarning} from 'sentry/icons';
  36. import {t} from 'sentry/locale';
  37. import ConfigStore from 'sentry/stores/configStore';
  38. import {space} from 'sentry/styles/space';
  39. import type {DateString} from 'sentry/types/core';
  40. import type {Series} from 'sentry/types/echarts';
  41. import type {Organization} from 'sentry/types/organization';
  42. import type {Project} from 'sentry/types/project';
  43. import toArray from 'sentry/utils/array/toArray';
  44. import {DiscoverDatasets, SavedQueryDatasets} from 'sentry/utils/discover/types';
  45. import getDuration from 'sentry/utils/duration/getDuration';
  46. import getDynamicText from 'sentry/utils/getDynamicText';
  47. import {shouldShowOnDemandMetricAlertUI} from 'sentry/utils/onDemandMetrics/features';
  48. import {MINUTES_THRESHOLD_TO_DISPLAY_SECONDS} from 'sentry/utils/sessions';
  49. import {capitalize} from 'sentry/utils/string/capitalize';
  50. import normalizeUrl from 'sentry/utils/url/normalizeUrl';
  51. import {useLocation} from 'sentry/utils/useLocation';
  52. import {useNavigate} from 'sentry/utils/useNavigate';
  53. import useOrganization from 'sentry/utils/useOrganization';
  54. import {COMPARISON_DELTA_OPTIONS} from 'sentry/views/alerts/rules/metric/constants';
  55. import {makeDefaultCta} from 'sentry/views/alerts/rules/metric/metricRulePresets';
  56. import type {MetricRule} from 'sentry/views/alerts/rules/metric/types';
  57. import {AlertRuleTriggerType, Dataset} from 'sentry/views/alerts/rules/metric/types';
  58. import {shouldUseErrorsDiscoverDataset} from 'sentry/views/alerts/rules/utils';
  59. import {getChangeStatus} from 'sentry/views/alerts/utils/getChangeStatus';
  60. import {AlertWizardAlertNames} from 'sentry/views/alerts/wizard/options';
  61. import {getAlertTypeFromAggregateDataset} from 'sentry/views/alerts/wizard/utils';
  62. import {hasDatasetSelector} from 'sentry/views/dashboards/utils';
  63. import {useMetricEventStats} from 'sentry/views/issueDetails/metricIssues/useMetricEventStats';
  64. import {useMetricSessionStats} from 'sentry/views/issueDetails/metricIssues/useMetricSessionStats';
  65. import type {Anomaly, Incident} from '../../../types';
  66. import {
  67. alertDetailsLink,
  68. alertTooltipValueFormatter,
  69. isSessionAggregate,
  70. } from '../../../utils';
  71. import {isCrashFreeAlert} from '../utils/isCrashFreeAlert';
  72. import type {TimePeriodType} from './constants';
  73. import {
  74. getMetricAlertChartOption,
  75. transformSessionResponseToSeries,
  76. } from './metricChartOption';
  77. interface MetricChartProps {
  78. filter: string[] | null;
  79. interval: string;
  80. project: Project;
  81. query: string;
  82. rule: MetricRule;
  83. theme: Theme;
  84. timePeriod: TimePeriodType;
  85. anomalies?: Anomaly[];
  86. formattedAggregate?: string;
  87. incidents?: Incident[];
  88. isOnDemandAlert?: boolean;
  89. }
  90. function formatTooltipDate(date: moment.MomentInput, format: string): string {
  91. const {
  92. options: {timezone},
  93. } = ConfigStore.get('user');
  94. return moment.tz(date, timezone).format(format);
  95. }
  96. export function getRuleChangeSeries(
  97. rule: MetricRule,
  98. data: AreaChartSeries[],
  99. theme: Theme
  100. ): LineSeriesOption[] {
  101. const {dateModified} = rule;
  102. if (!data.length || !data[0]!.data.length || !dateModified) {
  103. return [];
  104. }
  105. const seriesData = data[0]!.data;
  106. const seriesStart = new Date(seriesData[0]!.name).getTime();
  107. const ruleChanged = new Date(dateModified).getTime();
  108. if (ruleChanged < seriesStart) {
  109. return [];
  110. }
  111. return [
  112. {
  113. type: 'line',
  114. markLine: MarkLine({
  115. silent: true,
  116. animation: false,
  117. lineStyle: {color: theme.gray200, type: 'solid', width: 1},
  118. data: [{xAxis: ruleChanged}],
  119. label: {
  120. show: false,
  121. },
  122. }),
  123. markArea: MarkArea({
  124. silent: true,
  125. itemStyle: {
  126. color: color(theme.gray100).alpha(0.42).rgb().string(),
  127. },
  128. data: [[{xAxis: seriesStart}, {xAxis: ruleChanged}]],
  129. }),
  130. data: [],
  131. },
  132. ];
  133. }
  134. export default function MetricChart({
  135. rule,
  136. project,
  137. timePeriod,
  138. query,
  139. anomalies,
  140. isOnDemandAlert,
  141. interval,
  142. filter,
  143. incidents,
  144. formattedAggregate,
  145. }: MetricChartProps) {
  146. const theme = useTheme();
  147. const location = useLocation();
  148. const navigate = useNavigate();
  149. const organization = useOrganization();
  150. const shouldUseSessionsStats = isCrashFreeAlert(rule.dataset);
  151. const handleZoom = useCallback(
  152. (start: DateString, end: DateString) => {
  153. navigate({
  154. pathname: location.pathname,
  155. query: {start, end},
  156. });
  157. },
  158. [location.pathname, navigate]
  159. );
  160. const renderEmpty = useCallback((placeholderText = '') => {
  161. return (
  162. <ChartPanel>
  163. <PanelBody withPadding>
  164. <TriggerChartPlaceholder>{placeholderText}</TriggerChartPlaceholder>
  165. </PanelBody>
  166. </ChartPanel>
  167. );
  168. }, []);
  169. const renderEmptyOnDemandAlert = useCallback(
  170. (org: Organization, timeseriesData: Series[] = [], loading?: boolean) => {
  171. if (
  172. loading ||
  173. !isOnDemandAlert ||
  174. !shouldShowOnDemandMetricAlertUI(org) ||
  175. !isEmptySeries(timeseriesData[0]!)
  176. ) {
  177. return null;
  178. }
  179. return (
  180. <OnDemandMetricAlert
  181. dismissable
  182. message={t(
  183. 'This alert lacks historical data due to filters for which we don’t routinely extract metrics.'
  184. )}
  185. />
  186. );
  187. },
  188. [isOnDemandAlert]
  189. );
  190. const renderChartActions = useCallback(
  191. (
  192. totalDuration: number,
  193. criticalDuration: number,
  194. warningDuration: number,
  195. waitingForDataDuration: number
  196. ) => {
  197. let dataset: DiscoverDatasets | undefined = undefined;
  198. if (shouldUseErrorsDiscoverDataset(query, rule.dataset, organization)) {
  199. dataset = DiscoverDatasets.ERRORS;
  200. }
  201. let openInDiscoverDataset: SavedQueryDatasets | undefined = undefined;
  202. if (hasDatasetSelector(organization)) {
  203. if (rule.dataset === Dataset.ERRORS) {
  204. openInDiscoverDataset = SavedQueryDatasets.ERRORS;
  205. } else if (
  206. rule.dataset === Dataset.TRANSACTIONS ||
  207. rule.dataset === Dataset.GENERIC_METRICS
  208. ) {
  209. openInDiscoverDataset = SavedQueryDatasets.TRANSACTIONS;
  210. }
  211. }
  212. const {buttonText, ...props} = makeDefaultCta({
  213. organization,
  214. projects: [project],
  215. rule,
  216. timePeriod,
  217. query,
  218. dataset,
  219. openInDiscoverDataset,
  220. });
  221. const resolvedPercent =
  222. (100 *
  223. Math.max(
  224. totalDuration - waitingForDataDuration - criticalDuration - warningDuration,
  225. 0
  226. )) /
  227. totalDuration;
  228. const criticalPercent = 100 * Math.min(criticalDuration / totalDuration, 1);
  229. const warningPercent = 100 * Math.min(warningDuration / totalDuration, 1);
  230. const waitingForDataPercent =
  231. 100 *
  232. Math.min(
  233. (waitingForDataDuration - criticalDuration - warningDuration) / totalDuration,
  234. 1
  235. );
  236. return (
  237. <StyledChartControls>
  238. <StyledInlineContainer>
  239. <Fragment>
  240. <SectionHeading>{t('Summary')}</SectionHeading>
  241. <StyledSectionValue>
  242. <ValueItem>
  243. <IconCheckmark color="successText" isCircled />
  244. {resolvedPercent ? resolvedPercent.toFixed(2) : 0}%
  245. </ValueItem>
  246. <ValueItem>
  247. <IconWarning color="warningText" />
  248. {warningPercent ? warningPercent.toFixed(2) : 0}%
  249. </ValueItem>
  250. <ValueItem>
  251. <IconFire color="errorText" />
  252. {criticalPercent ? criticalPercent.toFixed(2) : 0}%
  253. </ValueItem>
  254. {waitingForDataPercent > 0 && (
  255. <StyledTooltip
  256. underlineColor="gray200"
  257. showUnderline
  258. title={t(
  259. 'The time spent waiting for metrics matching the filters used.'
  260. )}
  261. >
  262. <ValueItem>
  263. <IconClock />
  264. {waitingForDataPercent.toFixed(2)}%
  265. </ValueItem>
  266. </StyledTooltip>
  267. )}
  268. </StyledSectionValue>
  269. </Fragment>
  270. </StyledInlineContainer>
  271. {!isSessionAggregate(rule.aggregate) &&
  272. (getAlertTypeFromAggregateDataset(rule) === 'eap_metrics' ? (
  273. <Feature features="visibility-explore-view">
  274. <Button size="sm" {...props}>
  275. {buttonText}
  276. </Button>
  277. </Feature>
  278. ) : (
  279. <Feature features="discover-basic">
  280. <Button size="sm" {...props}>
  281. {buttonText}
  282. </Button>
  283. </Feature>
  284. ))}
  285. </StyledChartControls>
  286. );
  287. },
  288. [rule, organization, project, timePeriod, query]
  289. );
  290. const renderChart = useCallback(
  291. (
  292. loading: boolean,
  293. timeseriesData?: Series[],
  294. minutesThresholdToDisplaySeconds?: number,
  295. comparisonTimeseriesData?: Series[]
  296. ) => {
  297. const {start, end} = timePeriod;
  298. if (loading || !timeseriesData) {
  299. return renderEmpty();
  300. }
  301. const handleIncidentClick = (incident: Incident) => {
  302. navigate(
  303. normalizeUrl({
  304. pathname: alertDetailsLink(organization, incident),
  305. query: {alert: incident.identifier},
  306. })
  307. );
  308. };
  309. const {
  310. criticalDuration,
  311. warningDuration,
  312. totalDuration,
  313. waitingForDataDuration,
  314. chartOption,
  315. } = getMetricAlertChartOption({
  316. timeseriesData,
  317. rule,
  318. seriesName: formattedAggregate,
  319. incidents,
  320. anomalies,
  321. showWaitingForData:
  322. shouldShowOnDemandMetricAlertUI(organization) && isOnDemandAlert,
  323. handleIncidentClick,
  324. });
  325. const comparisonSeriesName = capitalize(
  326. COMPARISON_DELTA_OPTIONS.find(({value}) => value === rule.comparisonDelta)
  327. ?.label || ''
  328. );
  329. const additionalSeries: LineSeriesOption[] = [
  330. ...(comparisonTimeseriesData || []).map(({data: _data, ...otherSeriesProps}) =>
  331. LineSeries({
  332. name: comparisonSeriesName,
  333. data: _data.map(({name, value}) => [name, value]),
  334. lineStyle: {color: theme.gray200, type: 'dashed', width: 1},
  335. itemStyle: {color: theme.gray200},
  336. animation: false,
  337. animationThreshold: 1,
  338. animationDuration: 0,
  339. ...otherSeriesProps,
  340. })
  341. ),
  342. ...getRuleChangeSeries(rule, timeseriesData, theme),
  343. ];
  344. const queryFilter =
  345. filter?.join(' ') + t(' over ') + getDuration(rule.timeWindow * 60);
  346. return (
  347. <ChartPanel>
  348. <StyledPanelBody withPadding>
  349. <ChartHeader>
  350. <HeaderTitleLegend>
  351. {AlertWizardAlertNames[getAlertTypeFromAggregateDataset(rule)]}
  352. </HeaderTitleLegend>
  353. </ChartHeader>
  354. <ChartFilters>
  355. <StyledCircleIndicator size={8} />
  356. <Filters>{formattedAggregate ?? rule.aggregate}</Filters>
  357. <Tooltip
  358. title={queryFilter}
  359. isHoverable
  360. skipWrapper
  361. overlayStyle={{
  362. maxWidth: '90vw',
  363. lineBreak: 'anywhere',
  364. textAlign: 'left',
  365. }}
  366. showOnlyOnOverflow
  367. >
  368. <QueryFilters>{queryFilter}</QueryFilters>
  369. </Tooltip>
  370. </ChartFilters>
  371. {getDynamicText({
  372. value: (
  373. <ChartZoom
  374. start={start}
  375. end={end}
  376. onZoom={zoomArgs => handleZoom(zoomArgs.start, zoomArgs.end)}
  377. >
  378. {zoomRenderProps => (
  379. <AreaChart
  380. {...zoomRenderProps}
  381. {...chartOption}
  382. showTimeInTooltip
  383. minutesThresholdToDisplaySeconds={minutesThresholdToDisplaySeconds}
  384. additionalSeries={additionalSeries}
  385. tooltip={getMetricChartTooltipFormatter({
  386. formattedAggregate,
  387. rule,
  388. interval,
  389. comparisonSeriesName,
  390. theme,
  391. })}
  392. />
  393. )}
  394. </ChartZoom>
  395. ),
  396. fixed: <Placeholder height="200px" testId="skeleton-ui" />,
  397. })}
  398. </StyledPanelBody>
  399. {renderChartActions(
  400. totalDuration,
  401. criticalDuration,
  402. warningDuration,
  403. waitingForDataDuration
  404. )}
  405. </ChartPanel>
  406. );
  407. },
  408. [
  409. anomalies,
  410. filter,
  411. formattedAggregate,
  412. handleZoom,
  413. incidents,
  414. interval,
  415. isOnDemandAlert,
  416. navigate,
  417. organization,
  418. renderChartActions,
  419. renderEmpty,
  420. rule,
  421. theme,
  422. timePeriod,
  423. ]
  424. );
  425. const {data: eventStats, isLoading: isLoadingEventStats} = useMetricEventStats(
  426. {
  427. project,
  428. rule,
  429. timePeriod,
  430. referrer: 'api.alerts.alert-rule-chart',
  431. },
  432. {enabled: !shouldUseSessionsStats}
  433. );
  434. const {data: sessionStats, isLoading: isLoadingSessionStats} = useMetricSessionStats(
  435. {
  436. project,
  437. rule,
  438. timePeriod,
  439. },
  440. {
  441. enabled: shouldUseSessionsStats,
  442. }
  443. );
  444. const isLoading = isLoadingEventStats || isLoadingSessionStats;
  445. const timeSeriesData = shouldUseSessionsStats
  446. ? transformSessionResponseToSeries(sessionStats ?? null, rule)
  447. : transformTimeseriesData(eventStats?.data ?? [], eventStats?.meta, rule.aggregate);
  448. const minutesThresholdToDisplaySeconds = shouldUseSessionsStats
  449. ? MINUTES_THRESHOLD_TO_DISPLAY_SECONDS
  450. : undefined;
  451. const comparisonTimeseriesData = rule.comparisonDelta
  452. ? transformComparisonTimeseriesData(eventStats?.data ?? [])
  453. : [];
  454. return (
  455. <Fragment>
  456. {shouldUseSessionsStats
  457. ? null
  458. : renderEmptyOnDemandAlert(organization, timeSeriesData, isLoading)}
  459. {renderChart(
  460. isLoading,
  461. timeSeriesData,
  462. minutesThresholdToDisplaySeconds,
  463. comparisonTimeseriesData
  464. )}
  465. </Fragment>
  466. );
  467. }
  468. export function getMetricChartTooltipFormatter({
  469. interval,
  470. rule,
  471. theme,
  472. comparisonSeriesName,
  473. formattedAggregate,
  474. }: {
  475. interval: string;
  476. rule: MetricRule;
  477. theme: Theme;
  478. comparisonSeriesName?: string;
  479. formattedAggregate?: string;
  480. }): AreaChartProps['tooltip'] {
  481. const {dateModified, timeWindow} = rule;
  482. function formatter(seriesParams: TopLevelFormatterParams) {
  483. // seriesParams can be object instead of array
  484. const pointSeries = toArray(seriesParams);
  485. // @ts-expect-error TS(2339): Property 'marker' does not exist on type 'Callback... Remove this comment to see the full error message
  486. const {marker, data: pointData} = pointSeries[0];
  487. const seriesName = formattedAggregate ?? pointSeries[0]?.seriesName ?? '';
  488. const [pointX, pointY] = pointData as [number, number];
  489. const pointYFormatted = alertTooltipValueFormatter(
  490. pointY,
  491. seriesName,
  492. rule.aggregate
  493. );
  494. const isModified = dateModified && pointX <= new Date(dateModified).getTime();
  495. const startTime = formatTooltipDate(moment(pointX), 'MMM D LT');
  496. const {period, periodLength} = parseStatsPeriod(interval) ?? {
  497. periodLength: 'm',
  498. period: `${timeWindow}`,
  499. };
  500. const endTime = formatTooltipDate(
  501. moment(pointX).add(parseInt(period!, 10), periodLength),
  502. 'MMM D LT'
  503. );
  504. const comparisonSeries =
  505. pointSeries.length > 1
  506. ? pointSeries.find(({seriesName: _sn}) => _sn === comparisonSeriesName)
  507. : undefined;
  508. // @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
  509. const comparisonPointY = comparisonSeries?.data[1] as number | undefined;
  510. const comparisonPointYFormatted =
  511. comparisonPointY !== undefined
  512. ? alertTooltipValueFormatter(comparisonPointY, seriesName, rule.aggregate)
  513. : undefined;
  514. const changePercentage =
  515. comparisonPointY === undefined
  516. ? NaN
  517. : ((pointY - comparisonPointY) * 100) / comparisonPointY;
  518. const changeStatus = getChangeStatus(
  519. changePercentage,
  520. rule.thresholdType,
  521. rule.triggers
  522. );
  523. const changeStatusColor =
  524. changeStatus === AlertRuleTriggerType.CRITICAL
  525. ? theme.red300
  526. : changeStatus === AlertRuleTriggerType.WARNING
  527. ? theme.yellow300
  528. : theme.green300;
  529. return [
  530. `<div class="tooltip-series">`,
  531. isModified &&
  532. `<div><span class="tooltip-label"><strong>${t(
  533. 'Alert Rule Modified'
  534. )}</strong></span></div>`,
  535. `<div><span class="tooltip-label">${marker} <strong>${seriesName}</strong></span>${pointYFormatted}</div>`,
  536. comparisonSeries &&
  537. `<div><span class="tooltip-label">${comparisonSeries.marker} <strong>${comparisonSeriesName}</strong></span>${comparisonPointYFormatted}</div>`,
  538. `</div>`,
  539. `<div class="tooltip-footer">`,
  540. `<span>${startTime} &mdash; ${endTime}</span>`,
  541. comparisonPointY !== undefined &&
  542. Math.abs(changePercentage) !== Infinity &&
  543. !isNaN(changePercentage) &&
  544. `<span style="color:${changeStatusColor};margin-left:10px;">${
  545. Math.sign(changePercentage) === 1 ? '+' : '-'
  546. }${Math.abs(changePercentage).toFixed(2)}%</span>`,
  547. `</div>`,
  548. '<div class="tooltip-arrow"></div>',
  549. ]
  550. .filter(e => e)
  551. .join('');
  552. }
  553. return {formatter};
  554. }
  555. const ChartPanel = styled(Panel)`
  556. margin-top: ${space(2)};
  557. `;
  558. const ChartHeader = styled('div')`
  559. margin-bottom: ${space(3)};
  560. `;
  561. const StyledChartControls = styled(ChartControls)`
  562. display: flex;
  563. justify-content: space-between;
  564. flex-wrap: wrap;
  565. `;
  566. const StyledInlineContainer = styled(InlineContainer)`
  567. grid-auto-flow: column;
  568. grid-column-gap: ${space(1)};
  569. `;
  570. const StyledCircleIndicator = styled(CircleIndicator)`
  571. background: ${p => p.theme.formText};
  572. height: ${space(1)};
  573. margin-right: ${space(0.5)};
  574. `;
  575. const ChartFilters = styled('div')`
  576. font-size: ${p => p.theme.fontSizeSmall};
  577. font-family: ${p => p.theme.text.family};
  578. color: ${p => p.theme.textColor};
  579. display: inline-grid;
  580. grid-template-columns: max-content max-content auto;
  581. align-items: center;
  582. `;
  583. const Filters = styled('span')`
  584. margin-right: ${space(1)};
  585. `;
  586. const QueryFilters = styled('span')`
  587. min-width: 0px;
  588. ${p => p.theme.overflowEllipsis}
  589. `;
  590. const StyledSectionValue = styled(SectionValue)`
  591. display: grid;
  592. grid-template-columns: repeat(4, auto);
  593. gap: ${space(1.5)};
  594. margin: 0 0 0 ${space(1.5)};
  595. `;
  596. const ValueItem = styled('div')`
  597. display: grid;
  598. grid-template-columns: repeat(2, auto);
  599. gap: ${space(0.5)};
  600. align-items: center;
  601. font-variant-numeric: tabular-nums;
  602. text-underline-offset: ${space(4)};
  603. `;
  604. /* Override padding to make chart appear centered */
  605. const StyledPanelBody = styled(PanelBody)`
  606. padding-right: 6px;
  607. `;
  608. const TriggerChartPlaceholder = styled(Placeholder)`
  609. height: 200px;
  610. text-align: center;
  611. padding: ${space(3)};
  612. `;
  613. const StyledTooltip = styled(Tooltip)`
  614. text-underline-offset: ${space(0.5)} !important;
  615. `;