Files
superset2/superset/assets/visualizations/deckgl/layers/path.jsx
Maxime Beauchemin ff2f85f39b [geo] JS function to receive the whole data array instead of individual object (#4262)
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.
2018-01-24 13:16:14 -08:00

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),
});
}