averageValueMarkLine.tsx 794 B

12345678910111213141516171819202122232425262728293031323334
  1. import {useTheme} from '@emotion/react';
  2. import MarkLine from 'sentry/components/charts/components/markLine';
  3. import {t} from 'sentry/locale';
  4. interface Props {
  5. value?: number;
  6. }
  7. export function AverageValueMarkLine({value}: Props = {}) {
  8. const theme = useTheme();
  9. return MarkLine({
  10. data: [
  11. // If a `value` is provided, set the markline to that value. If not, `type: 'average'` will automatically set it
  12. {
  13. valueDim: 'y',
  14. type: 'average',
  15. yAxis: value,
  16. },
  17. ],
  18. lineStyle: {
  19. color: theme.gray400,
  20. },
  21. emphasis: {disabled: true},
  22. label: {
  23. position: 'insideEndBottom',
  24. formatter: () => t(`Average`),
  25. fontSize: 14,
  26. color: theme.chartLabel,
  27. backgroundColor: theme.chartOther,
  28. },
  29. });
  30. }