Skip to content

Commit

Permalink
fix(stats): Correct release count tooltip data (#73690)
Browse files Browse the repository at this point in the history
Fixes a tooltip on a graph on the team stats page
  • Loading branch information
scttcper authored Jul 2, 2024
1 parent ef389a4 commit f2d307a
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions static/app/views/organizationStats/teamInsights/teamReleases.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {Fragment} from 'react';
import type {Theme} from '@emotion/react';
import {css, withTheme} from '@emotion/react';
import {css, useTheme} from '@emotion/react';
import styled from '@emotion/styled';
import round from 'lodash/round';
import moment from 'moment';
Expand Down Expand Up @@ -30,7 +29,6 @@ interface TeamReleasesProps extends DateTimeObject {
organization: Organization;
projects: Project[];
teamSlug: string;
theme: Theme;
}

export type ProjectReleaseCount = {
Expand All @@ -43,12 +41,12 @@ function TeamReleases({
organization,
projects,
teamSlug,
theme,
start,
end,
period,
utc,
}: TeamReleasesProps) {
const theme = useTheme();
const datetime = {start, end, period, utc};

const {
Expand Down Expand Up @@ -210,16 +208,22 @@ function TeamReleases({
},
]}
tooltip={{
formatter: seriesParams => {
formatter: (seriesParams: any) => {
// `seriesParams` can be an array or an object :/
const [series] = toArray(seriesParams);

if (!series.data?.value) {
return '';
}

const dateFormat = 'MMM D';
const startDate = moment(series.data[0]).format(dateFormat);
const endDate = moment(series.data[0]).add(7, 'days').format(dateFormat);
const startDate = moment(series.data.value[0]).format(dateFormat);
const endDate = moment(series.data.value[0])
.add(7, 'days')
.format(dateFormat);
return [
'<div class="tooltip-series">',
`<div><span class="tooltip-label">${series.marker} <strong>${series.seriesName}</strong></span> ${series.data[1]}</div>`,
`<div><span class="tooltip-label">${series.marker} <strong>${series.seriesName}</strong></span> ${series.data.value[1]}</div>`,
`<div><span class="tooltip-label"><strong>Last ${period} Average</strong></span> ${totalPeriodAverage}</div>`,
'</div>',
`<div class="tooltip-footer">${startDate} - ${endDate}</div>`,
Expand Down Expand Up @@ -282,7 +286,7 @@ function TeamReleases({
);
}

export default withTheme(TeamReleases);
export default TeamReleases;

const ChartWrapper = styled('div')`
padding: ${space(2)} ${space(2)} 0 ${space(2)};
Expand Down

0 comments on commit f2d307a

Please sign in to comment.