durationChart.tsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import type {Series} from 'sentry/types/echarts';
  2. import {MutableSearch} from 'sentry/utils/tokenizeSearch';
  3. import {AVG_COLOR} from 'sentry/views/insights/colors';
  4. import Chart, {ChartType} from 'sentry/views/insights/common/components/chart';
  5. import ChartPanel from 'sentry/views/insights/common/components/chartPanel';
  6. import {getDurationChartTitle} from 'sentry/views/insights/common/views/spans/types';
  7. import {ALERTS} from 'sentry/views/insights/database/alerts';
  8. import {CHART_HEIGHT} from 'sentry/views/insights/database/settings';
  9. import type {SpanMetricsQueryFilters} from 'sentry/views/insights/types';
  10. interface Props {
  11. isLoading: boolean;
  12. series: Series[];
  13. error?: Error | null;
  14. filters?: SpanMetricsQueryFilters;
  15. }
  16. export function DurationChart({series, isLoading, error, filters}: Props) {
  17. const filterString = filters && MutableSearch.fromQueryObject(filters).formatString();
  18. const alertConfig = {...ALERTS.duration, query: filterString ?? ALERTS.duration.query};
  19. return (
  20. <ChartPanel title={getDurationChartTitle('db')} alertConfigs={[alertConfig]}>
  21. <Chart
  22. height={CHART_HEIGHT}
  23. grid={{
  24. left: '0',
  25. right: '0',
  26. top: '8px',
  27. bottom: '0',
  28. }}
  29. data={series}
  30. loading={isLoading}
  31. error={error}
  32. chartColors={[AVG_COLOR]}
  33. type={ChartType.LINE}
  34. />
  35. </ChartPanel>
  36. );
  37. }