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): Set aliases per plottable in TimeSeriesWidgetVisualization (#87023)
We allow plottables to have aliases. e.g.,
```jsx
const timeSeries = {
field: 'failure_rate_5()',
...
<TimeSeriesWidgetVisualization
plottables={[
new Line(timeSeries)
]}
aliases={{'failure_rate_5()': '5XX'}}
/>
```
That makes it easy to set nice aliases for long series names in charts.
This is not a great API for a few reasons:
1. Aliases have to be constructed ahead of time. Sometimes this is easy,
sometime it's annoying, if you're calculating aliases as the same time
as constructing the plottables
2. This won't work well in the near future. Right now we're passing
around objects with properties like `field: "/insights,prod : eps()"`
which is impractical. We're going to break that stuff up
3. This works like crap for charts that have different series with the
same `field`, like if you're showing different `avg(span.duration)` from
different queries, for example
This PR changes the API, and now every plottable can specify its alias,
which is much more explicit!
e.g.,
```jsx
const timeSeries = {
field: 'failure_rate_5()',
...
<TimeSeriesWidgetVisualization
plottables={[
new Line(timeSeries, {alias: '5XX'})
]}
/>
```
Each plottable has a `label` property that either returns the alias, or
computes a default value if needed. It sets the label directly on the
output `Series` so we don't have to do any additional processing at
tooltip time 👍🏻
N.B. `InsightsTimeSeriesWidget` still accepts `aliases` and then passes
them along to the right plottable. That's just for convenience in that
case, I'll be gradually thinning that component out.
0 commit comments