mirror of
https://github.com/apache/superset.git
synced 2026-05-30 12:49:17 +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.
30 lines
736 B
JavaScript
30 lines
736 B
JavaScript
import { PathLayer } from 'deck.gl';
|
|
|
|
import * as common from './common';
|
|
import sandboxedEval from '../../../javascripts/modules/sandbox';
|
|
|
|
export default function getLayer(formData, payload, slice) {
|
|
const fd = formData;
|
|
const c = fd.color_picker;
|
|
const fixedColor = [c.r, c.g, c.b, 255 * c.a];
|
|
let data = payload.data.features.map(feature => ({
|
|
...feature,
|
|
path: feature.path,
|
|
width: fd.line_width,
|
|
color: fixedColor,
|
|
}));
|
|
|
|
if (fd.js_data_mutator) {
|
|
const jsFnMutator = sandboxedEval(fd.js_data_mutator);
|
|
data = jsFnMutator(data);
|
|
}
|
|
|
|
return new PathLayer({
|
|
id: `path-layer-${fd.slice_id}`,
|
|
data,
|
|
rounded: true,
|
|
widthScale: 1,
|
|
...common.commonLayerProps(fd, slice),
|
|
});
|
|
}
|