Skip to content
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

[DC-710]Add mocked visualizations and total cohort count #5114

Open
wants to merge 17 commits into
base: dev
Choose a base branch
from

Conversation

rjohanek
Copy link
Contributor

@rjohanek rjohanek commented Sep 26, 2024

Jira Ticket: https://broadworkbench.atlassian.net/browse/DC-710

Summary of changes:

  1. adds total cohort count to page
  2. moves save cohort button over to be inline with cohorts
  3. adds randomly generated data visualizations that re-generate when the cohort is updated
    a. adds code to randomly generate numbers
    b. adds graph data to state to trigger re-render
    c. blocks rendering of graph on return of count endpoint

Why

demographic visualizations are helpful to researchers building a cohort

Testing strategy

Unit tests of helper functions
Test that count appears on page
Test that graphs appear on page

Visual Aids

Screen.Recording.2024-10-04.at.2.03.00.PM.mov

setTimeout(() => {
cohortAgeData.series = generateAgeSeries(3, 90);
setCohortAges(cohortAgeData);
}, 2000);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure this timeout is doing everything I want it to do. It does stop a double re-render (like without it, the graphs re-render when the async count method is called and again when it is returned), but I wanted to add a timeout so that it would return at a similar time as the async count call and it isn't doing that even if I increase the time. What am I missing here?

Copy link
Contributor

Choose a reason for hiding this comment

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

So, I wouldn't expect you to need both the timeout and the useEffect subscribed to snapshotRequestParticipantCount. This effect should be called whenever snapshotRequestParticipantCount is updated. The trick might be that snapshotRequestParticipantCount is a useLoadedData hook, so you probably need to check the status of useLoadedData and only display/update when it is 'Ready'

setTimeout(() => {
cohortAgeData.series = generateAgeSeries(3, 90);
setCohortAges(cohortAgeData);
}, 2000);
Copy link
Contributor

Choose a reason for hiding this comment

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

So, I wouldn't expect you to need both the timeout and the useEffect subscribed to snapshotRequestParticipantCount. This effect should be called whenever snapshotRequestParticipantCount is updated. The trick might be that snapshotRequestParticipantCount is a useLoadedData hook, so you probably need to check the status of useLoadedData and only display/update when it is 'Ready'

src/dataset-builder/CohortEditor.ts Show resolved Hide resolved
@rjohanek rjohanek marked this pull request as ready for review October 3, 2024 14:25
@rjohanek rjohanek requested a review from a team as a code owner October 3, 2024 14:25
@rjohanek rjohanek changed the title rough draft: add static visualizations and total cohort count [DC-710] add static visualizations and total cohort count Oct 3, 2024
@rjohanek rjohanek changed the title [DC-710] add static visualizations and total cohort count [DC-710]Add mocked visualizations and total cohort count Oct 3, 2024
Copy link

sonarcloud bot commented Oct 3, 2024

{ name: 'Pacific Islander', data: [] },
];
// for each of the three gender identity totals,
const genderTotals = generateRandomNumbersThatAddUpTo(100, 3);
Copy link
Contributor

Choose a reason for hiding this comment

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

Just as a note - and its dummy data so not a big deal, but I think we would want it to add up to the number of participants, not to 100?

That said, I think trying to get the dummy data perfect is not worth the effort, and just letting it render charts seems fine to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the graph is based on the overall percentage of participants not the number of participants. that's how it was in the mock

showSeriesName: boolean;
}

export function generateCohortAgeData(series) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This function doesn't seem like test data to me, since its the chart definition. I'd move this into the component.

generateCohortDemographicData(defaultCohortDemographicSeries)
);
const countStatus = snapshotRequestParticipantCount.status;
function chartOptions(cohortDemographics: CohortDemographics) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The charts are meaty enough they may be worth an intermediate component, so that we can isolate the chart configuration. What are your thoughts on that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah I think that's a good idea

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants