mirror of
https://github.com/apache/superset.git
synced 2026-06-01 13:49:21 +00:00
Moving from having the user define an interceptor function that operates on one object at a time. By passing the entire array, it's possible to do multiple pass where needed. A common pattern might be to figure out the max value in order to define a scaler function. That's only possible if dealing with the whole array.
29 lines
754 B
JavaScript
29 lines
754 B
JavaScript
import { PolygonLayer } from 'deck.gl';
|
|
|
|
import * as common from './common';
|
|
import sandboxedEval from '../../../javascripts/modules/sandbox';
|
|
|
|
export default function polygonLayer(formData, payload, slice) {
|
|
const fd = formData;
|
|
const fc = fd.fill_color_picker;
|
|
let data = payload.data.features.map(d => ({
|
|
...d,
|
|
fillColor: [fc.r, fc.g, fc.b, 255 * fc.a],
|
|
}));
|
|
|
|
if (fd.js_data_mutator) {
|
|
// Applying user defined data mutator if defined
|
|
const jsFnMutator = sandboxedEval(fd.js_data_mutator);
|
|
data = jsFnMutator(data);
|
|
}
|
|
|
|
return new PolygonLayer({
|
|
id: `path-layer-${fd.slice_id}`,
|
|
data,
|
|
filled: fd.filled,
|
|
stroked: fd.stoked,
|
|
extruded: fd.extruded,
|
|
...common.commonLayerProps(fd, slice),
|
|
});
|
|
}
|