Refactor: Enhance WebstatusLineChartPanel
with data fetching, aggregation, and additional series calculations
#1175
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:FetchFunctionConfig
objects.SeriesCalculator
functions to calculate additional series data based onAdditionalSeriesConfig
configurations.data-fetch-starting
anddata-fetch-complete
events to communicate data fetching progress and results.FetchFunctionConfig
andAdditionalSeriesConfig
: 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:getTooltip
method to allow customization of tooltips for individual data points.timestampExtractor
andvalueExtractor
concepts from the feature detail page charts to provide more flexibility in handling different data structures.WebstatusStatsGlobalFeatureCountChartPanel
andWebstatusStatsMissingOneImplChartPanel
: 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.