performance.tsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import type {LineChartProps} from 'sentry/components/charts/lineChart';
  2. import {transformToLineSeries} from 'sentry/components/charts/lineChart';
  3. import getBreakpointChartOptionsFromData, {
  4. type EventBreakpointChartData,
  5. } from 'sentry/components/events/eventStatisticalDetector/breakpointChartOptions';
  6. import {lightTheme as theme} from 'sentry/utils/theme';
  7. import {slackChartDefaults, slackChartSize} from './slack';
  8. import type {RenderDescriptor} from './types';
  9. import {ChartType} from './types';
  10. export const performanceCharts: RenderDescriptor<ChartType>[] = [];
  11. function modifyOptionsForSlack(options: Omit<LineChartProps, 'series'>) {
  12. options.legend = options.legend || {};
  13. options.legend.icon = 'none';
  14. options.legend.left = '25';
  15. options.legend.top = '20';
  16. return {
  17. ...options,
  18. grid: slackChartDefaults.grid,
  19. visualMap: options.options?.visualMap,
  20. };
  21. }
  22. performanceCharts.push({
  23. key: ChartType.SLACK_PERFORMANCE_ENDPOINT_REGRESSION,
  24. getOption: (data: EventBreakpointChartData) => {
  25. const {chartOptions, series} = getBreakpointChartOptionsFromData(data, theme);
  26. const transformedSeries = transformToLineSeries({series});
  27. const modifiedOptions = modifyOptionsForSlack(chartOptions);
  28. return {
  29. ...modifiedOptions,
  30. backgroundColor: theme.background,
  31. series: transformedSeries,
  32. grid: slackChartDefaults.grid,
  33. visualMap: modifiedOptions.options?.visualMap,
  34. };
  35. },
  36. ...slackChartSize,
  37. });