Skip to content

feat(explore-suspect-attrs): Iterating on series data, sorting or dat… #95401

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: abdk/explore-suspect-tags-chart-labels
Choose a base branch
from

Conversation

Abdkhan14
Copy link
Contributor

…a and tooltip

cohortsToSeriesData takes the cohorts and assigns a value of '0' to the chart series data if a label is not present in a cohort. Example: cohort1: {'prod': 1, 'local': 2} and cohort2: {'local': 3} -----> series_cohort_1: [{label: 'prod', value: '1'},{label: 'local', value: '2'}] and series_cohort_2: [{label: 'prod', value: '0'},{label: 'local', value: '3'}]

Note: Removed confining of tooltip, it will be cut off at the boundaries. Will set appendToBody:true (which pushes the tooltip up to document.body) along with the virtualization PR, otherwise the screen freezes trying to do it for too many charts.

@Abdkhan14 Abdkhan14 requested a review from a team as a code owner July 12, 2025 22:59
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Jul 12, 2025
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Chart Tooltips Show NaN or Infinity Percentages

The chart tooltips display incorrect percentages ("NaN%" or "Infinity%") due to two issues:

  1. In valueFormatter, seriesTotals are incorrectly accessed using the category label instead of the seriesName.
  2. Both valueFormatter and formatAxisLabel perform division by zero when cohort totals are zero.

static/app/views/explore/components/suspectTags/charts.tsx#L125-L134

const valueFormatter = useCallback(
(_value: number, label?: string, seriesParams?: CallbackDataParams) => {
const data = Number(seriesParams?.data);
const total = seriesTotals[label as keyof typeof seriesTotals];
const percentage = (data / total) * 100;
return `${percentage.toFixed(1)}%`;
},
[seriesTotals]
);

static/app/views/explore/components/suspectTags/charts.tsx#L159-L165

const selectedData = Number(selectedParam?.data);
const selectedPercentage = (selectedData / selectedTotal) * 100;
const baselineTotal =
seriesTotals[baselineParam?.seriesName as keyof typeof seriesTotals];
const baselineData = Number(baselineParam?.data);
const baselinePercentage = (baselineData / baselineTotal) * 100;

Fix in CursorFix in Web


Bug: Chart Tooltip Percentage Calculation Error

The formatAxisLabel function in charts.tsx incorrectly calculates and displays percentages in tooltips. It assumes a fixed order for selected and baseline series parameters instead of identifying them by seriesName, leading to misattributed data. Additionally, it performs division by zero when cohort totals are zero, resulting in NaN% or Infinity%. The function also includes overly strict error handling that throws an error if expected series parameters are undefined, potentially crashing the application.

static/app/views/explore/components/suspectTags/charts.tsx#L149-L166

const selectedParam = seriesParamsOrParam[0];
const baselineParam = seriesParamsOrParam[1];
if (!selectedParam || !baselineParam) {
throw new Error('selectedParam or baselineParam is not defined');
}
const selectedTotal =
seriesTotals[selectedParam?.seriesName as keyof typeof seriesTotals];
const selectedData = Number(selectedParam?.data);
const selectedPercentage = (selectedData / selectedTotal) * 100;
const baselineTotal =
seriesTotals[baselineParam?.seriesName as keyof typeof seriesTotals];
const baselineData = Number(baselineParam?.data);
const baselinePercentage = (baselineData / baselineTotal) * 100;

Fix in CursorFix in Web


Was this report helpful? Give feedback by reacting with 👍 or 👎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Frontend Automatically applied to PRs that change frontend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant