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] Remove client-side scaling of ordinal values #58528

Merged

Conversation

thomasneirynck
Copy link
Contributor

@thomasneirynck thomasneirynck commented Feb 25, 2020

Since 7.6, styles have access to the actual min-max for numerical values. Client-side scaling to the [0-1] range is no longer necessary to create a valid mb-style rule. Maps can use the actual min/max.

This PR is a prerequisite to support dynamic-styling on non-geojson vector-sources (e.g. .mvt vector tiles). In those instances, Maps cannot get the data-ranges by cycling over the result-set, rather Maps can access them through other means (e.g. metadata request for ES-backed data, TileJson-manifest inspection, manually inputs of users, ...).

This PR has no end-user impact.

@thomasneirynck thomasneirynck requested a review from a team as a code owner February 25, 2020 20:33
@thomasneirynck thomasneirynck added chore v7.7.0 v8.0.0 [Deprecated-Use Team:Presentation]Team:Geo Former Team Label for Geo Team. Now use Team:Presentation labels Feb 25, 2020
@elasticmachine
Copy link
Contributor

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

@thomasneirynck thomasneirynck added the release_note:skip Skip the PR/issue when compiling release notes label Feb 25, 2020
@@ -34,22 +34,6 @@ export function isOnlySingleFeatureType(featureType, supportedFeatures, hasFeatu
}, true);
}

export function scaleValue(value, range) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I still think we need to preserve this logic and snap NaN values to less then min so they have the same behavior and do not cause errors. Also, snapping values less then min and over max need to be preserved. When using aggregations to fetch min/max, there will be values greater than and less then min/max

Copy link
Contributor Author

@thomasneirynck thomasneirynck Feb 26, 2020

Choose a reason for hiding this comment

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

thanks, agreed.

After discussion, we're moving this clamping to the actual mb-expression. This way, we do not need to retain this separate scaleValue code-path. It has following template:

['max', ['min', ['to-number', [lookupFunction, fieldName]], maxValue], minValue],

@nreese
Copy link
Contributor

nreese commented Feb 27, 2020

makeMbClampedNumberExpression is not correct for empty values. to-number returns zero for null. Null should be set to lessThenFirstStopValue value and not zero

Here is an example data set to highlight the problem

PUT test
{
  "mappings": {
    "properties": {
      "location": {
        "type": "geo_point"
      }
    }
  }
}

PUT test/_doc/1
{
  "location": [0, 0],
  "prop1": 1
}

PUT test/_doc/2
{
  "location": [10, 0]
}

PUT test/_doc/3
{
  "location": [20, 0],
  "prop1": -1
}

On Master, the fill color is transparent with no value. That is the documented behavior for missing values.
Screen Shot 2020-02-27 at 12 34 02 PM

Screen Shot 2020-02-27 at 12 09 26 PM

In this branch, fill color is incorrectly placed in middle of ramp, because zero is in the middle of 1 and -1, when there is no value.
Screen Shot 2020-02-27 at 12 26 31 PM

@thomasneirynck
Copy link
Contributor Author

thx @nreese that example will be super helpful to work on resolving this.

@thomasneirynck
Copy link
Contributor Author

@elasticmachine merge upstream

Copy link
Contributor

@nreese nreese left a comment

Choose a reason for hiding this comment

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

This is a great improvement and gets us one step closer to using vector tiles to display _search results. Thanks
lgtm
code review, tested in chrome

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

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

@thomasneirynck thomasneirynck merged commit 88d41fa into elastic:master Mar 23, 2020
@thomasneirynck
Copy link
Contributor Author

Will wait to backport to 7.x until 7.7 branch is cut. This PR has no direct user impact, and there is no reason to merge this to a released branch without actual end-user benefits.

thomasneirynck added a commit to thomasneirynck/kibana that referenced this pull request Mar 25, 2020
This removes the rescaling of ordinal values to the [0,1] domain, and modifies the creation of the mapbox-style rules to use the actual RangeStyleMeta-data. This is an important prerequisite for Maps handling tile vector sources. For these sources, Maps does not have access to the raw underlying GeoJson and needs to use the stylemeta directly.
@kibanamachine
Copy link
Contributor

Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync.

@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Mar 25, 2020
@thomasneirynck
Copy link
Contributor Author

backport to 7.x: #61344

nreese pushed a commit that referenced this pull request Mar 25, 2020
This removes the rescaling of ordinal values to the [0,1] domain, and modifies the creation of the mapbox-style rules to use the actual RangeStyleMeta-data. This is an important prerequisite for Maps handling tile vector sources. For these sources, Maps does not have access to the raw underlying GeoJson and needs to use the stylemeta directly.
@kibanamachine kibanamachine removed the backport missing Added to PRs automatically when the are determined to be missing a backport. label Mar 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport pending chore [Deprecated-Use Team:Presentation]Team:Geo Former Team Label for Geo Team. Now use Team:Presentation release_note:skip Skip the PR/issue when compiling release notes v7.8.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants