metricChart.tsx 22 KB

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