metricChart.tsx 22 KB

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