mirror of
https://github.com/visgl/react-map-gl.git
synced 2026-01-25 16:02:50 +00:00
15 lines
409 B
JavaScript
15 lines
409 B
JavaScript
import {range} from 'd3-array';
|
|
import {scaleQuantile} from 'd3-scale';
|
|
|
|
export function updatePercentiles(featureCollection, accessor) {
|
|
const {features} = featureCollection;
|
|
const scale = scaleQuantile()
|
|
.domain(features.map(accessor))
|
|
.range(range(9));
|
|
features.forEach(f => {
|
|
const value = accessor(f);
|
|
f.properties.value = value;
|
|
f.properties.percentile = scale(value);
|
|
});
|
|
}
|