chart.tsx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import {useTheme} from '@emotion/react';
  2. import {AreaChart} from 'sentry/components/charts/areaChart';
  3. import {axisLabelFormatter} from 'sentry/utils/discover/charts';
  4. import {getDuration} from 'sentry/utils/formatters';
  5. type Props = React.ComponentPropsWithoutRef<typeof AreaChart>;
  6. function Chart(props: Props) {
  7. const theme = useTheme();
  8. return (
  9. <AreaChart
  10. grid={{left: '10px', right: '10px', top: '40px', bottom: '0px'}}
  11. xAxis={{
  12. type: 'category' as const,
  13. truncate: true,
  14. axisLabel: {
  15. showMinLabel: true,
  16. showMaxLabel: true,
  17. },
  18. axisTick: {
  19. interval: 0,
  20. alignWithLabel: true,
  21. },
  22. }}
  23. yAxis={{
  24. type: 'value' as const,
  25. axisLabel: {
  26. color: theme.chartLabel,
  27. // Use p50() to force time formatting.
  28. formatter: (value: number) => axisLabelFormatter(value, 'p50()'),
  29. },
  30. }}
  31. tooltip={{valueFormatter: value => getDuration(value / 1000, 2)}}
  32. {...props}
  33. />
  34. );
  35. }
  36. export default Chart;