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

[7.x] [Maps] Correctly handle single-feature joins (#30409) #30469

Merged
merged 1 commit into from
Feb 8, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions x-pack/plugins/maps/public/shared/layers/styles/vector_style.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,21 @@ export class VectorStyle extends AbstractStyle {
max = Math.max(max, newValue);
}
}
//scale to [0,1]
const diff = max - min;
const propName = VectorStyle.getComputedFieldName(fieldName);

//scale to [0,1] domain
for (let i = 0; i < features.length; i++) {
features[i].properties[propName] = (features[i].properties[fieldName] - min) / (max - min);
const unscaledValue = features[i].properties[fieldName];
let scaledValue;
if (typeof unscaledValue !== 'number' || isNaN(unscaledValue)) {//cannot scale
scaledValue = -1;//put outside range
} else if (diff === 0) {//values are identical
scaledValue = 1;//snap to end of color range
} else {
scaledValue = (features[i].properties[fieldName] - min) / diff;
}
features[i].properties[propName] = scaledValue;
}
featureCollection.computed.push(fieldName);
return true;
Expand Down