releaseSeries.tsx 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import type {Theme} from '@emotion/react';
  2. import MarkLine from 'sentry/components/charts/components/markLine';
  3. import {t} from 'sentry/locale';
  4. import type {Series} from 'sentry/types/echarts';
  5. import {escape} from 'sentry/utils';
  6. import {getFormattedDate} from 'sentry/utils/dates';
  7. import {formatVersion} from 'sentry/utils/versions/formatVersion';
  8. import type {Release} from '../common/types';
  9. export function ReleaseSeries(
  10. theme: Theme,
  11. releases: Release[],
  12. onClick: (release: Release) => void,
  13. utc: boolean
  14. ): Series {
  15. return {
  16. seriesName: t('Releases'),
  17. color: theme.purple200,
  18. data: [],
  19. markLine: MarkLine({
  20. animation: false,
  21. lineStyle: {
  22. color: theme.purple300,
  23. opacity: 0.3,
  24. type: 'solid',
  25. },
  26. label: {
  27. show: false,
  28. },
  29. data: releases.map(release => ({
  30. xAxis: new Date(release.timestamp).getTime(),
  31. name: formatVersion(release.version, true),
  32. value: formatVersion(release.version, true),
  33. onClick: () => {
  34. onClick(release);
  35. },
  36. label: {
  37. formatter: () => formatVersion(release.version, true),
  38. },
  39. })),
  40. tooltip: {
  41. trigger: 'item',
  42. formatter: function (params: any) {
  43. const time = getFormattedDate(params.value, 'MMM D, YYYY LT', {
  44. local: utc,
  45. });
  46. const version = escape(formatVersion(params.name, true));
  47. return [
  48. '<div class="tooltip-series">',
  49. `<div><span class="tooltip-label"><strong>${t(
  50. 'Release'
  51. )}</strong></span> ${version}</div>`,
  52. '</div>',
  53. '<div class="tooltip-footer">',
  54. time,
  55. '</div>',
  56. '<div class="tooltip-arrow"></div>',
  57. ].join('');
  58. },
  59. },
  60. }),
  61. };
  62. }