-
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
Ensure custom set axis titles are preserved when loading a saved vis. #24176
Conversation
$parentScope.updateAxisTitle(); | ||
expect($parentScope.editorState.params.valueAxes[0].title.text).to.equal('Count'); | ||
}); | ||
|
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.
Added the above 2 tests to validate existing editor behavior which was previously untested
$parentScope.editorState.aggs[0].params.customLabel = 'Custom Label'; | ||
$parentScope.updateAxisTitle(); | ||
expect($parentScope.editorState.params.valueAxes[0].title.text).to.equal('Custom Title'); | ||
}); |
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 is the test that validates the actual change made in this PR
💔 Build Failed |
Jenkins, test this |
💔 Build Failed |
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.
I am just a bit worried about the tests. They currently (and most likely already have beforehand) relied on a specific execution order, even though they are unit tests. Do you think we could modify the tests, to actually setup the scope from scratch for every test into the state it needs to be?
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.
Code LGTM. Tested on OSX/Chrome.
As Tim suggested it would be also useful to have a functional test, where the test follow the exact path you have described on the PR description, involving saving of the visualization going back to the visualization list and back again to the visualization.
retest |
💔 Build Failed |
retest |
💔 Build Failed |
@lukeelmers can you merge master? I've already seen this CI error (https://kibana-ci.elastic.co/job/elastic+kibana+pull-request+multijob-x-pack/7590/console). Not sure if was the merging or the retesting that solves that problem |
@@ -158,8 +158,11 @@ module.directive('vislibValueAxes', function () { | |||
label = matchingSeries[0].makeLabel(); | |||
} | |||
if (lastAxisTitles[axis.id] !== label && label !== '') { | |||
// Only overwrite the custom title with the value axis label if it hasn't been changed | |||
if (lastAxisTitles[axis.id] === axis.title.text) { |
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.
wouldn't we want to change the title automatically if the actual aggregation was changed, or a field ?
- select sum over bytes field
- go to axes, change title from sum of bytes to
sum of bytes downloaded
- go back to data tab, and change field to something else ... what would you expect in this case ?
- what about if you completely changed aggregation ?
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.
@ppisljar Good catch -- it feels to me the expected behavior in the cases you've described would be that the custom title gets cleared when the agg type or field changes. I will give it some thought and follow up in a bit.
899957c
to
1d4cfeb
Compare
Okay, I think I finally got to some behavior that I feel makes sense while still solving the original issue:
See below and notice how the axis title & legend change based on what is changed in the editor: I've also rebased on the latest master so (hopefully) we will get a green build now. Updated tests to follow shortly. The one item this doesn't address is resetting the axis title when the agg field changes. This issue affects |
@@ -136,10 +136,11 @@ module.directive('vislibValueAxes', function () { | |||
}, 1); | |||
}; | |||
|
|||
const lastAxisTitles = {}; | |||
const lastCustomLabels = {}; |
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.
I changed some variable names to make this all a little easier to follow.
💚 Build Succeeded |
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.
LGTM, tested on chrome linux
1d4cfeb
to
9872708
Compare
💚 Build Succeeded |
…alization. Previously, the visualization editor would lose a custom set axis title every time you opened the editor and loaded a visualization or if you changed the actual aggregation label. This was due to the way that agg labels were overwriting custom axis titles. This change simply checks to ensure the custom title hasn't already been changed before overwriting it with an updated agg label.
9872708
to
6e6d168
Compare
💚 Build Succeeded |
No further notes from my side, please feel free to merge and also backport to 6.x and 6.5 |
Fixes #24145
Summary
Previously, the visualization editor would lose a custom set axis title every
time you opened the editor and loaded a visualization or if you changed the
actual aggregation label. This was due to the way that agg labels were
overwriting custom axis titles.
This change simply checks to ensure the custom title hasn't already been
changed before overwriting it with an updated agg label.
Testing
Data
tab, set a custom label "A" for your y-axis agg.Metrics & Axes
tab, and you will see the custom label "A" has been copied as the custom y-axis title.apply
.save
, exit the editor, go back tovisualizations
and re-open the vis.Metrics & Axes
tab, you should continue to see the same title "B" (this is what was broken prior to this PR -- previously you would have seen "A" in the input field).Checklist
[ ] This was checked for cross-browser compatibility, including a check against IE11[ ] Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support[ ] Documentation was added for features that require explanation or tutorials[ ] This was checked for keyboard-only and screenreader accessibilityFor maintainers
[ ] This was checked for breaking API changes and was labeled appropriately[ ] This includes a feature addition or change that requires a release note and was labeled appropriately