import {Fragment} from 'react';
import {useTheme} from '@emotion/react';
import {BarChart} from 'sentry/components/charts/barChart';
import BarChartZoom from 'sentry/components/charts/barChartZoom';
import ErrorPanel from 'sentry/components/charts/errorPanel';
import {HeaderTitleLegend} from 'sentry/components/charts/styles';
import TransitionChart from 'sentry/components/charts/transitionChart';
import TransparentLoadingMask from 'sentry/components/charts/transparentLoadingMask';
import {pickBarColor} from 'sentry/components/performance/waterfall/utils';
import Placeholder from 'sentry/components/placeholder';
import QuestionTooltip from 'sentry/components/questionTooltip';
import {IconWarning} from 'sentry/icons';
import {t} from 'sentry/locale';
import type {Organization} from 'sentry/types/organization';
import {axisLabelFormatter, tooltipFormatter} from 'sentry/utils/discover/charts';
import type EventView from 'sentry/utils/discover/eventView';
import {aggregateOutputType} from 'sentry/utils/discover/fields';
import getDynamicText from 'sentry/utils/getDynamicText';
import SpanHistogramQuery from 'sentry/utils/performance/histogram/spanHistogramQuery';
import type {HistogramData} from 'sentry/utils/performance/histogram/types';
import {
computeBuckets,
formatHistogramData,
} from 'sentry/utils/performance/histogram/utils';
import type {SpanSlug} from 'sentry/utils/performance/suspectSpans/types';
import {decodeScalar} from 'sentry/utils/queryString';
import {useLocation} from 'sentry/utils/useLocation';
import {ZoomKeys} from './utils';
const NUM_BUCKETS = 50;
const PRECISION = 0;
type Props = {
eventView: EventView;
organization: Organization;
spanSlug: SpanSlug;
};
export default function ExclusiveTimeHistogram(props: Props) {
const {organization, eventView, spanSlug} = props;
const location = useLocation();
const start = decodeScalar(location.query[ZoomKeys.MIN]);
const end = decodeScalar(location.query[ZoomKeys.MAX]);
return (
{t('Self Time Distribution')}
{({histogram, isLoading, error}) => {
if (error) {
return (
);
}
return (
{zoomRenderProps => (
)}
);
}}
);
}
type ChartProps = {
chartData: HistogramData | null;
isErrored: boolean;
isLoading: boolean;
spanSlug: SpanSlug;
zoomProps: any;
disableChartPadding?: boolean;
};
export function Chart(props: ChartProps) {
const theme = useTheme();
const {chartData, zoomProps, spanSlug} = props;
if (!chartData) {
return ;
}
const chartOptions = {
grid: {
left: '10px',
right: '10px',
top: '40px',
bottom: '0px',
},
colors: () => pickBarColor(spanSlug.op),
seriesOptions: {
showSymbol: false,
},
tooltip: {
trigger: 'axis' as const,
// TODO (udameli) pull series name from the meta
valueFormatter: (value, _seriesName) =>
tooltipFormatter(value, aggregateOutputType(_seriesName)),
},
yAxis: {
type: 'value' as const,
axisLabel: {
color: theme.chartLabel,
formatter: (value: number) => axisLabelFormatter(value, 'number'),
},
},
xAxis: {
type: 'category' as const,
truncate: true,
axisTick: {
alignWithLabel: true,
},
},
height: 200,
};
const series = {
seriesName: t('Count'),
data: formatHistogramData(chartData, {type: 'duration'}),
};
return (
{getDynamicText({
value: ,
fixed: ,
})}
);
}