import Feature from 'sentry/components/acl/feature'; import OptionSelector from 'sentry/components/charts/optionSelector'; import { ChartContainer, ChartControls, InlineContainer, SectionHeading, SectionValue, } from 'sentry/components/charts/styles'; import Count from 'sentry/components/count'; import Panel from 'sentry/components/panels/panel'; import {t} from 'sentry/locale'; import type {Organization} from 'sentry/types/organization'; import {defined} from 'sentry/utils'; import {trackAnalytics} from 'sentry/utils/analytics'; import {browserHistory} from 'sentry/utils/browserHistory'; import type EventView from 'sentry/utils/discover/eventView'; import type {SpanSlug} from 'sentry/utils/performance/suspectSpans/types'; import {decodeScalar} from 'sentry/utils/queryString'; import {useLocation} from 'sentry/utils/useLocation'; import ExclusiveTimeHistogram from './exclusiveTimeHistogram'; import ExclusiveTimeTimeSeries from './exclusiveTimeTimeSeries'; type Props = { eventView: EventView; organization: Organization; spanSlug: SpanSlug; totalCount?: number; }; enum DisplayModes { TIMESERIES = 'timeseries', HISTOGRAM = 'histogram', } function Chart(props: Props) { const location = useLocation(); const display = decodeScalar(location.query.display, DisplayModes.TIMESERIES); function generateDisplayOptions() { return [ {value: DisplayModes.TIMESERIES, label: t('Self Time Breakdown')}, {value: DisplayModes.HISTOGRAM, label: t('Self Time Distribution')}, ]; } function handleDisplayChange(value: string) { trackAnalytics('performance_views.span_summary.change_chart', { organization: props.organization, change_to_display: value, }); browserHistory.push({ pathname: location.pathname, query: { ...location.query, display: value, }, }); } return ( {({hasFeature}) => { if (hasFeature) { if (display === DisplayModes.TIMESERIES) { return ; } return ; } return ; }} {t('Total Events')} {defined(props.totalCount) ? : '\u2014'} ); } export default Chart;