ref(dashboards): Move unit scaling into Plottable
#86116
+170
−68
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 is a refactor of the
Plottable
interface. It clarifies and separates the type definitions, and moves some ugly mutation logic away out of the React component and into the constructor classes.This is an important step on the road to multi-type charts, where lines and bars can coexist. It'll become a lot clearer when the public API for
TimeSeriesWidgetVisualization
starts accepting plottables directly.Changes
The first change is a clarification of the types, and their relationships.
Plottable
is a generic interface. APlottable
is an object that can be put into ECharts. Right now, only one kind of plottable is implemented:PlottableData
, but others are coming (e.g., Releases, and later other marker types). Right now,PlottableData
is only used under-the-hood inTimeSeriesDataVisualization
, but soon this will be the public API. Charts will be created by passing various plottable items to the componentArea
,Line
, andBars
all implement thePlottableData
interface. They do this by extending theAggreateTimeSeries
plottable.AggregateTimeSeries
is there for sharing code. It specifies the constructor, and some simple scaling logic. Soon, this class will have more interesting properties that will make coordinating data between different plottables easierThe second change is smaller, and more subtle. It moves data scaling into the plottables. This creates just a bit of code duplication, but is much nicer because this logic is now hidden from the chart (so I can improve it later).