-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Lens] Multiple y axes #69911
[Lens] Multiple y axes #69911
Conversation
Pinging @elastic/kibana-app (Team:KibanaApp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So far I've tested the behavior, and it's looking promising. Did something change with the way we do axis titles in this PR? I'm noticing the comma-separated titles more.
Will review code next week.
@elasticmachine merge upstream |
@wylieconlon I added this logic, but as you are mentioning it I remembered we chose to only use the first series as label here to avoid overly long axis labels. Rolled back that change @mbondyra Renamed the expression functions so we can add colors in there as well. Also, I fixed the bug with the unformatted value in the tooltip. |
💚 Build SucceededBuild metrics
History
To update your PR or re-run it, just comment with: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tested on Firefox, it works great! Code looks good to me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM, thanks for making those changes!
@@ -276,6 +276,9 @@ export function XYChart({ | |||
legendPosition={legend.position} | |||
showLegendExtra={false} | |||
theme={chartTheme} | |||
tooltip={{ | |||
headerFormatter: (d) => xAxisFormatter.convert(d.value), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does of course fail if there are non-matching types on the X axis, but I think we can't fix that case.
…-based-rbac * upstream/master: (38 commits) Move logger configuration integration test to jest (elastic#70378) Changes observability plugin codeowner (elastic#70439) update (elastic#70424) [Logs UI] Avoid CCS-incompatible index name resolution (elastic#70179) Enable "Explore underlying data" actions for Lens visualizations (elastic#70047) Initial work on uptime homepage API (elastic#70135) expressions indexPattern function (elastic#70315) [Discover] Deangularization context error message refactoring (elastic#70090) [Lens] Add "no data" popover (elastic#69147) [Lens] Move chart switcher over (elastic#70182) chore: add missing mjs extension (elastic#70326) [Lens] Multiple y axes (elastic#69911) skip flaky suite (elastic#70386) fix bug to add timeline to case (elastic#70343) [QA][Code Coverage] Drop catchError and use try / catch instead, (elastic#69198) [QA] [Code Coverage] Integrate with Team Assignment Pipeline and Add Research and Development Indexes and Cluster (elastic#69348) [Metrics UI] Add context.reason and alertOnNoData to Inventory alerts (elastic#70260) Resolver refactoring (elastic#70312) [Ingest Manager] Fix agent ack after input format change (elastic#70335) [eslint][ts] Enable prefer-ts-expect-error (elastic#70022) ...
Fixes #53663
Fixes #68260
This PR adds the ability to configure two separate y axes in XY charts.
These changes are limited to the xy visualization, expect for one small fix in
x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx
- there is a flagenableDimensionEditor
on the dimension group whether to show a second visualization-controlled tab in the dimension editor, but it wasn't used to actually determine whether to show the editor or not.Axis assignment
The process of assigning metric to axes follows this algorithm:
A formatter is compatible if it has the same type, e.g.
number
orbytes
.There are other ways of handling this (e.g. displaying multiple axes on a single side if the formatters don't match), but all approaches (including the chosen one) have non-optimal edge cases. These can only be really fixed by providing a more sophisticated way of editing axes which would be out of scope for this PR. We can add this in a later iteration by providing a separate axis management menu in the toolbar.
Subtle changes
yTitle
andxTitle
argument on the expression to label the axes - so farxTitle
was only used when there was no column name provided by the data source (never in practice). As we can have multiple y axes now as well, by default the names of the participating columns are used, with theyTitle
as fallback (like it's happening forxTitle
).Expression integration
Currently y axis series are specified by listing out the columns in the
accessors
argument. To stay compatible with previous versions and not introduce too much new structure, this PR simply adds anyAxisConfiguration
argument that can be specified multiple times, setting the axis mode to either left, right or auto. As long as the user didn't select anything, no state is written and "auto" mode is assumed. If the user manually picks an axis mode, alens_xy_yAxisConfiguration
sub-expression is added:Related to that: In
x-pack/plugins/lens/public/xy_visualization/types.ts
there were expression functions forYState
andXConfig
which were unused, I removed them as part of this PR.lens_xy_yConfig
can be extended later to add things like metric color overrides.elastic-charts
integrationTo use multiple axes, they have to be defined with a
groupId
, then series can be mapped to them by specifying the samegroupId
. Currently there is a single series element in the spec for each layer, but it's possible to have a single layer mapped to different axes. This PR makes this possible, by splitting up each layer for each y accessor, keeping all other properties the same except for the group id which is mapped for each accessor individually. That changes existing specs with more than one metric (e.g. turning oneLineSeries
element into multiple ones).