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

Refactor: Introduce WebstatusFeatureUsageChartPanel and WebstatusFeatureWPTProgressChartPanel using WebstatusLineChartPanel #1176

Merged
merged 2 commits into from
Feb 19, 2025

Conversation

jcscottiii
Copy link
Collaborator

@jcscottiii jcscottiii commented Feb 18, 2025

Depends on #1175

This PR introduces two new custom elements, WebstatusFeatureUsageChartPanel and WebstatusFeatureWPTProgressChartPanel, for displaying feature usage and WPT progress charts, respectively. These components leverage the enhanced WebstatusLineChartPanel abstract class, promoting code reuse and consistency across different chart panels.

Key changes:

  • WebstatusFeatureUsageChartPanel: This panel displays the usage statistics of a feature over time. It fetches data using the getChromiumDailyUsageStats API call and visualizes it using a line chart.
  • WebstatusFeatureWPTProgressChartPanel: This panel displays the WPT (Web Platform Tests) progress of a feature across different browsers. It fetches data using the getFeatureStatsByBrowserAndChannel API call and visualizes it using a line chart with an additional "Total" series calculated using the calculateMax method.
  • Simplified FeaturePage: By introducing these new components, the FeaturePage is significantly simplified. It no longer needs to handle the loading and displaying of individual charts, as these tasks are now delegated to the respective chart panel components.
  • Leveraging data-fetch-complete event: The FeaturePage now listens for the data-fetch-complete event dispatched by the WebstatusFeatureWPTProgressChartPanel to calculate and display the percentage difference in WPT results, similar to the previous implementation.
  • Behavior changes:
    • Loading state: Instead of a separate full page loading overlay, the components now use the built-in loading state of the WebstatusLineChartPanel abstract class. This aligns with the goal of issue Create component specific loading & error states #278 to move towards component-level loading states.
    • Chart display: The charts are now displayed only after all data is fetched, ensuring consistency with the stats page charts and simplifying the rendering logic.

This PR improves code organization and reusability by introducing dedicated chart panel components and leveraging the WebstatusLineChartPanel abstract class. It also simplifies the FeaturePage and provides a more consistent and streamlined user experience for viewing feature usage and WPT progress.

@jcscottiii jcscottiii marked this pull request as ready for review February 18, 2025 22:59
Base automatically changed from jcscottiii/more-line-chart-additions to main February 19, 2025 14:07
…eatureWPTProgressChartPanel` using `WebstatusLineChartPanel`

This PR introduces two new custom elements, `WebstatusFeatureUsageChartPanel` and `WebstatusFeatureWPTProgressChartPanel`, for displaying feature usage and WPT progress charts, respectively. These components leverage the enhanced `WebstatusLineChartPanel` abstract class, promoting code reuse and consistency across different chart panels.

**Key changes:**

* **`WebstatusFeatureUsageChartPanel`:** This panel displays the usage statistics of a feature over time. It fetches data using the `getChromiumDailyUsageStats` API call and visualizes it using a line chart.
* **`WebstatusFeatureWPTProgressChartPanel`:** This panel displays the WPT (Web Platform Tests) progress of a feature across different browsers. It fetches data using the `getFeatureStatsByBrowserAndChannel` API call and visualizes it using a line chart with an additional "Total" series calculated using the `calculateMax` method.
* **Simplified `FeaturePage`:** By introducing these new components, the `FeaturePage` is significantly simplified. It no longer needs to handle the loading and displaying of individual charts, as these tasks are now delegated to the respective chart panel components.
* **Leveraging `data-fetch-complete` event:** The `FeaturePage` now listens for the `data-fetch-complete` event dispatched by the `WebstatusFeatureWPTProgressChartPanel` to calculate and display the percentage difference in WPT results, similar to the previous implementation.
* **Behavior changes:**
    * **Loading state:** Instead of a separate full page loading overlay, the components now use the built-in loading state of the `WebstatusLineChartPanel` abstract class. This aligns with the goal of issue #278 to move towards component-level loading states.
    * **Chart display:** The charts are now displayed only after all data is fetched, ensuring consistency with the stats page charts and simplifying the rendering logic.

This PR improves code organization and reusability by introducing dedicated chart panel components and leveraging the `WebstatusLineChartPanel` abstract class. It also simplifies the `FeaturePage` and provides a more consistent and streamlined user experience for viewing feature usage and WPT progress.
@jcscottiii jcscottiii force-pushed the jcscottiii/use-generic-chart-on-feature-page branch from afe3637 to fb5d70c Compare February 19, 2025 14:11
Copy link
Collaborator

@jrobbins jrobbins left a comment

Choose a reason for hiding this comment

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

I assume that it is OK that some of the data points changed in the snapshots.

@jcscottiii
Copy link
Collaborator Author

jcscottiii commented Feb 19, 2025

@jrobbins That should be okay. I double checked my code against the actual live data. My charts looked mostly the same as the current ones in production. I say mostly because I did find one thing I am missing:

// We build a map from each time slot for which any browser has data.
// to an array of data for all browsers (in dateToBrowserDataMap)
// along with the total_tests_count for that time.
// Since times may be slightly different for data associated with each browser,
// we round times to the nearest 1 hour as a compromise.
// The total ought to be the same for all browsers,
// but this is not the case due to upstream problems.
// As a workaround, we will instead use the max of all the
// browser's totals for each time slot.
// So effectively, for each unique time slot, we merge the data
// for all the browsers while computing the max of the total value for
// each of the browsers.

const timestampMs = new Date(dateString).getTime();
// Round timestamp to the nearest hour.
const msInHour = 1000 * 60 * 60 * 1;
const roundedTimestamp = Math.round(timestampMs / msInHour) * msInHour;

This inconsistency is because of the data from WPT itself. So we try to create buckets for the WPT data to catch bad data. I am pushing up something now. It is simply using this same timestamp extractor in this new chart interface.

@jcscottiii jcscottiii added this pull request to the merge queue Feb 19, 2025
Merged via the queue into main with commit 0b07ca7 Feb 19, 2025
6 checks passed
@jcscottiii jcscottiii deleted the jcscottiii/use-generic-chart-on-feature-page branch February 19, 2025 21:43
@KyleJu KyleJu mentioned this pull request Feb 19, 2025
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.

[ENHANCEMENT] Refactor feature chart methods to be more generic and reusable
2 participants