You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ref(dashboards): Move unit scaling into Plottable (#86116)
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. A `Plottable` 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 in `TimeSeriesDataVisualization`, but soon this will be
the public API. Charts will be created by passing various plottable
items to the component
- `Area`, `Line`, and `Bars` all implement the `PlottableData`
interface. They do this by extending the `AggreateTimeSeries` 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 easier
- A plottable has a _configuration_ and _plotting options_. The
configuration has to do with the data. How much is that data delayed?
Does it have a specific color? The _plotting options_ have to do with
putting the plottable into ECharts. This answers questions like "what is
the fallback color?" and "what is the Y axis unit"? These things are
computed after taking all plottables into consideration
The 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).
* A `Plottable` is any object that can be converted to an ECharts `Series` and therefore plotted on an ECharts chart. This could be a data series, releases, samples, and other kinds of markers. `TimeSeriesWidgetVisualization` uses `Plottable` objects under the hood, to convert data coming into the component via props into ECharts series.
54
+
*/
55
+
interfacePlottable{
56
+
/**
57
+
*
58
+
* @param plottingOptions Plotting options depend on the specific implementation of the interface.
* `PlottableData` is any plottable that represents a data time series. The points in the series are a pair of a timestamp and a numeric value. This could be a continuous time series of aggregated data, or data samples.
65
+
*/
66
+
exportinterfacePlottableDataextendsPlottable{
67
+
/**
68
+
* @param options Plotting options. The resulting series will have the color `color`, and will be scaled to `unit` if needed.
* Final plottable color. If no color is specified in configuration, a fallback must be provided while attempting to plot
15
+
*/
16
+
color: string;
17
+
/**
18
+
* Final plottable unit. This might be different from the original unit of the data, because we scale all time series to a single common unit.
19
+
*/
20
+
unit: DurationUnit|SizeUnit|RateUnit|null;
21
+
};
22
+
23
+
/**
24
+
* `AggregateTimeSeries` is a plottable that represents a continuous data time series. This is used for tasks like plotting a changing duration over time, for example. This is distinct from plotting items like sample series, threshold lines, etc. This ABC is inherited by specific plottable time series like `Line`, `Area`, and `Bars` to enforce the interface and share functionality.
0 commit comments