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

[Agency Dashboard] DataVizStore implementation #186

Merged
merged 12 commits into from
Nov 30, 2022
Merged

Conversation

terryttsai
Copy link
Contributor

@terryttsai terryttsai commented Nov 29, 2022

Description of the change

Creation of DataVizStore to share data viz state across multiple different components, namely to use with the existing DatapointsView component and the MetricInsights component which I'm rendering on the left panel of the agency dashboard.

If Publisher and Agency Dashboard's charts continue to diverge, we could break up the entire DatapointsView component (which renders the chart, metric title, legend, insights, dropdowns, select metrics button) to its Publisher version and Agency Dashboard version. Right now it's one big component that conditionally renders some of the components depending on how its configured. But for now I'm going to leave this alone.

Type of change

All pull requests must have at least one of the following labels applied (otherwise the PR will fail):

Label Description
Type: Bug non-breaking change that fixes an issue
Type: Feature non-breaking change that adds functionality
Type: Breaking Change fix or feature that would cause existing functionality to not work as expected
Type: Non-breaking refactor change addresses some tech debt item or prepares for a later change, but does not change functionality
Type: Configuration Change adjusts configuration to achieve some end related to functionality, development, performance, or security
Type: Dependency Upgrade upgrades a project dependency - these changes are not included in release notes

Related issues

Closes #XXXX

Checklists

Development

This box MUST be checked by the submitter prior to merging:

  • Double- and triple-checked that there is no Personally Identifiable Information (PII) being mistakenly added in this pull request

These boxes should be checked by the submitter prior to merging:

  • Tests have been written to cover the code changed/added as part of this pull request

Code review

These boxes should be checked by reviewers prior to merging:

  • This pull request has a descriptive title and information useful to a reviewer
  • This pull request has been moved out of a Draft state, has no "Work In Progress" label, and has assigned reviewers
  • Potential security implications or infrastructural changes have been considered, if relevant

@terryttsai terryttsai changed the title [WIP] DataVizStore implemention [Agency Dashboard] DataVizStore implementation Nov 29, 2022
@terryttsai terryttsai requested a review from a team November 29, 2022 21:15
@terryttsai terryttsai marked this pull request as ready for review November 29, 2022 21:15
@terryttsai terryttsai closed this Nov 29, 2022
@terryttsai terryttsai reopened this Nov 29, 2022
Copy link
Collaborator

@lilidworkin lilidworkin left a comment

Choose a reason for hiding this comment

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

This is really cool!

If Publisher and Agency Dashboard's charts continue to diverge, we could break up the entire DatapointsView component (which renders the chart, metric title, legend, insights, dropdowns, select metrics button) to its Publisher version and Agency Dashboard version.

I agree that we should keep these together for now! We should push back against too much divergence here. Anytime the designs or functionality spec differs significantly between the two, we should call it out and discuss with Humphrey and Juan and see if there's a way to keep things more similar. (If you feel like things are already diverging a lot, it might be helpful to start keeping track of a list of things that are different?)

This is probably a very naive question, but I'm curious how this new store works when you switch metrics. Does the selected time range, disaggregation, etc. reset? Or does it persist?

common/components/DataViz/DatapointsView.tsx Show resolved Hide resolved
common/components/DataViz/utils.ts Show resolved Hide resolved
}
return filterNullDatapoints(filterByTimeRange(datapoints, monthsAgo));
};

// get insights from data
Copy link
Collaborator

Choose a reason for hiding this comment

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

super nit, should this comment be moved above transformDataForMetricInsights now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed comment to be more clear that these are calculations from already transformed data

if (datapoints.length === 0) {
return datapoints;
}
return filterNullDatapoints(filterByTimeRange(datapoints, monthsAgo));
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is probably a bit of a nit, but both of these helper functions (transform for bar and transform for metric insights) do the same null filtering and time range filtering. Is that redundant work? Is there a way to just do that once and then share it?

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 bar chart has the extra step of transforming for percent view but i'll share logic between them so thanks for pointing that out!

common/types.ts Outdated Show resolved Hide resolved
@terryttsai
Copy link
Contributor Author

The key parts that are different are the addition of the Select Metrics button and showing the Metric Insights in a separate component in the Agency Dashboard, and rendering the metric title in Publisher (which I think should probably be separated out from the DatapointsView component)

@terryttsai
Copy link
Contributor Author

It was difficult to figure out how to place the metric insights with the datapoints view so trying out putting it in the left panel made sense at the time

Copy link
Contributor

@mxosman mxosman left a comment

Choose a reason for hiding this comment

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

Looks good to me, Terry! Awesome to see how you're breaking this out and thinking about it.

@terryttsai terryttsai merged commit e7be62b into main Nov 30, 2022
@terryttsai terryttsai deleted the ttt/datavizstore branch November 30, 2022 20:35
@lilidworkin
Copy link
Collaborator

@terryttsai naive question but I'm curious how this new store works when you switch metrics. Does the selected time range, disaggregation, etc. reset? Or does it persist?

@terryttsai
Copy link
Contributor Author

Oh sorry I missed answering your question earlier—the behavior stays the same as before, since we're relying on react useEffects on the data viz component to reset these fields

@lilidworkin
Copy link
Collaborator

Ah thanks, makes sense!!

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

Successfully merging this pull request may close these issues.

3 participants