Skip to content
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

[XY] Fixes the formatting on multiple axis #115552

Merged
merged 2 commits into from
Oct 20, 2021

Conversation

stratoula
Copy link
Contributor

@stratoula stratoula commented Oct 19, 2021

Summary

Fixes #13866

This PR fixes a bug on the xy plugin. Specifically, it seems that when we have two metrics assigned to different axis, the format of each metric is not respected and only the formatter of the first field is taken under consideration for both axis.
This is wrong. We want this to work like lens, meaning that if we have 2 axes, each axis should have the correct format. If there are multiple metrics to the same axis then the format of the first metric is respected.

image

Note: the getConfig function is untested, so I created a unit test in order to test the bug fix and some other cases irrelevant with this PR.
I will create an issue to increase the coverage on this file as I think it calculates many important things and must be well tested.

Checklist

@stratoula stratoula changed the title [XY] fixes the formatting on multiple axis [XY] Fixes the formatting on multiple axis Oct 19, 2021
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
visTypeXy 61.7KB 61.7KB +74.0B

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@stratoula stratoula marked this pull request as ready for review October 20, 2021 06:03
@stratoula stratoula requested a review from a team as a code owner October 20, 2021 06:03
@stratoula stratoula added the Team:Visualizations Visualization editors, elastic-charts and infrastructure label Oct 20, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-vis-editors (Team:VisEditors)

);
const yAxes = params.valueAxes.map((a) => {
// find the correct aspect for each value axis
const aspectsIdx = params.seriesParams.findIndex((s) => s.valueAxis === a.id);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, I find this slightly more readable but feel free to ignore :) :

const aspectY = params.seriesParams.find((s) => s.valueAxis === a.id) || aspects.y[0];

And then in the line 59 you could just do aspectY

Copy link
Contributor Author

@stratoula stratoula Oct 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't do this unfortunately. I am retrieving the aspect idx from the seriesParams idx and then use it to retrieve the correct aspect. The params.seriesParams.find((s) => s.valueAxis === a.id) will return the seriesParam not the aspect!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh ok 👌🏼 Thanks for the explanation, makes sense!

Copy link
Contributor

@mbondyra mbondyra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on FF, the bug is fixed! 🙌🏼

@stratoula stratoula added the auto-backport Deprecated - use backport:version if exact versions are needed label Oct 20, 2021
@stratoula stratoula merged commit 453d4bc into elastic:master Oct 20, 2021
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Oct 20, 2021
* [XY] fixes the formatting on multiple axis

* Move mock data to its own file
@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
7.x

This backport PR will be merged automatically after passing CI.

kibanamachine added a commit that referenced this pull request Oct 20, 2021
* [XY] fixes the formatting on multiple axis

* Move mock data to its own file

Co-authored-by: Stratoula Kalafateli <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed Feature:XYAxis XY-Axis charts (bar, area, line) release_note:fix Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.16.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Defining multiple Y-Axis Metrics with different formatting for each uses the formatting of only one of them
4 participants