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: Enhance WebstatusLineChartPanel with data fetching, aggregation, and additional series calculations #1175

Merged
merged 1 commit into from
Feb 19, 2025

Conversation

jcscottiii
Copy link
Collaborator

This PR significantly enhances the WebstatusLineChartPanel abstract class by adding functionality for data fetching, aggregation, and calculation of additional series. These improvements streamline the creation of line chart panels and promote code reuse across different parts of the application. A lot of these changes come from or are inspired by things in the feature detail page. The removal of that code will come in the next PR when those charts implement WebstatusLineChartPanel.

Key changes:

  • _fetchAndAggregateData method: This new method centralizes the logic for fetching data from multiple sources, applying additional series calculations, and dispatching events. It simplifies the implementation of subclasses by handling common tasks like:
    • Fetching data concurrently using FetchFunctionConfig objects.
    • Applying SeriesCalculator functions to calculate additional series data based on AdditionalSeriesConfig configurations.
    • Dispatching data-fetch-starting and data-fetch-complete events to communicate data fetching progress and results.
  • FetchFunctionConfig and AdditionalSeriesConfig: These interfaces provide a structured way to define data sources and additional series calculations, promoting consistency and maintainability.
  • calculateMax calculator/aggregator: This utility function calculates the maximum value for each timestamp across multiple series, enabling easy creation of "Total" or "Max" series in charts.
  • LineChartMetricData enhancements:
    • Added an optional getTooltip method to allow customization of tooltips for individual data points.
    • Borrowed the timestampExtractor and valueExtractor concepts from the feature detail page charts to provide more flexibility in handling different data structures.
  • Improved loading and error states:
    • Set a minimum height of 300px for loading and error states to match the chart height and reduce jank.
    • Added a centered spinner and message to the loading state for a better user experience.
  • Removed multiple selection mode: Removed the multiple selection mode in the common Google chart settings to align with the behavior of feature detail page charts.
  • Refactored WebstatusStatsGlobalFeatureCountChartPanel and WebstatusStatsMissingOneImplChartPanel: These classes now use the _fetchAndAggregateData method, simplifying their code and removing the need to handle pages of data manually.
  • Other UI changes: Removed the header divider line between chart title and chart to be consistent with feature detail charts.

This PR improves the WebstatusLineChartPanel class's functionality and reusability, making it easier to create and maintain various line chart panels across the application. It also enhances the user experience with better loading and error states and promotes consistency by aligning chart behavior.

…gation, and additional series calculations

This PR significantly enhances the `WebstatusLineChartPanel` abstract class by adding functionality for data fetching, aggregation, and calculation of additional series. These improvements streamline the creation of line chart panels and promote code reuse across different parts of the application.

**Key changes:**

* **`_fetchAndAggregateData` method:** This new method centralizes the logic for fetching data from multiple sources, applying additional series calculations, and dispatching events. It simplifies the implementation of subclasses by handling common tasks like:
    * Fetching data concurrently using `FetchFunctionConfig` objects.
    * Applying `SeriesCalculator` functions to calculate additional series data based on `AdditionalSeriesConfig` configurations.
    * Dispatching `data-fetch-starting` and `data-fetch-complete` events to communicate data fetching progress and results.
* **`FetchFunctionConfig` and `AdditionalSeriesConfig`:** These interfaces provide a structured way to define data sources and additional series calculations, promoting consistency and maintainability.
* **`calculateMax` calculator/aggregator:** This utility function calculates the maximum value for each timestamp across multiple series, enabling easy creation of "Total" or "Max" series in charts.
* **`LineChartMetricData` enhancements:**
    * Added an optional `getTooltip` method to allow customization of tooltips for individual data points.
    * Borrowed the `timestampExtractor` and `valueExtractor` concepts from the feature detail page charts to provide more flexibility in handling different data structures.
* **Improved loading and error states:**
    * Set a minimum height of 300px for loading and error states to match the chart height and reduce jank.
    * Added a centered spinner and message to the loading state for a better user experience.
* **Removed multiple selection mode:** Removed the multiple selection mode in the common Google chart settings to align with the behavior of feature detail page charts.
* **Refactored `WebstatusStatsGlobalFeatureCountChartPanel` and `WebstatusStatsMissingOneImplChartPanel`:** These classes now use the `_fetchAndAggregateData` method, simplifying their code and removing the need to handle pages of data manually.

This PR improves the `WebstatusLineChartPanel` class's functionality and reusability, making it easier to create and maintain various line chart panels across the application. It also enhances the user experience with better loading and error states and promotes consistency by aligning chart behavior.
@jcscottiii jcscottiii added this pull request to the merge queue Feb 19, 2025
Merged via the queue into main with commit 32a5205 Feb 19, 2025
6 checks passed
@jcscottiii jcscottiii deleted the jcscottiii/more-line-chart-additions branch February 19, 2025 14:07
@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.

2 participants