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

[Maps] Fix custom color ramp on save #59953

Merged
merged 3 commits into from
Mar 12, 2020

Conversation

nreese
Copy link
Contributor

@nreese nreese commented Mar 11, 2020

Refactoring for categorical color palettes introduced a bug with ordinal custom color ramps. To view the bug, follow the following steps

  1. Create map with single document layer from web logs.
  2. Style fill color by value on the field bytes. Add at least 2 color stops
  3. Save the map by clicking save in the top nav. Notice that the map fill color is not longer styled after saving.

Before saving
Screen Shot 2020-03-11 at 2 13 26 PM

After saving
Screen Shot 2020-03-11 at 2 13 44 PM

The problem is this guard against incomplete color configuration, https://github.com/elastic/kibana/blob/7.6/x-pack/legacy/plugins/maps/public/layers/styles/vector/properties/dynamic_color_property.js#L108

const isDynamicConfigComplete =
      _.has(this._options, 'field.name') && _.has(this._options, 'color');
    if (!isDynamicConfigComplete) {
      return null;
    }

During the refactoring for categorical color palettes, styleOptions.color is getting removed from the options during save. This causes this guard to return false even though the color configuration is complete for custom color ramp.

This PR cleans up the logic of _getMbColor to better check for config completeness when using custom color ramps and palettes. The PR also adds some unit tests to ensure the various configurations work as expected.

@nreese nreese requested a review from a team as a code owner March 11, 2020 20:20
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-gis (Team:Geo)

Copy link
Contributor

@thomasneirynck thomasneirynck left a comment

Choose a reason for hiding this comment

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

thanks for fixing.

fwiw I wouldn't do this method rename in a spot-fix for a patch like this.

@@ -226,16 +223,6 @@ export class DynamicColorProperty extends DynamicStyleProperty {
return ['match', ['to-string', ['get', this._options.field.name]], ...mbStops];
}

_getMbOrdinalColorStops() {
Copy link
Contributor

Choose a reason for hiding this comment

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

thanks for removing and improving symmetry between cat and ordinal

@nreese
Copy link
Contributor Author

nreese commented Mar 11, 2020

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

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

@nreese nreese merged commit 021d904 into elastic:master Mar 12, 2020
nreese added a commit to nreese/kibana that referenced this pull request Mar 12, 2020
* [Maps] Fix custom color ramp on save

* clean up

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
nreese added a commit that referenced this pull request Mar 12, 2020
* [Maps] Fix custom color ramp on save

* clean up

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
nreese added a commit that referenced this pull request Mar 12, 2020
* merge with master

* fix jest test for 7.6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants