metricChart.tsx 22 KB

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