mirror of
https://github.com/apache/superset.git
synced 2026-05-12 19:35:17 +00:00
Using user-defined Javascript to customize geospatial visualization (#4173)
* Using JS to customize spatial viz and tooltips * Add missing deck_multi.png * Improve GeoJSON layer with JS support and extra controls * Addressing comments
This commit is contained in:
committed by
GitHub
parent
ee63ebc8ec
commit
87c3e831a8
@@ -1,19 +1,29 @@
|
||||
import { PathLayer } from 'deck.gl';
|
||||
|
||||
export default function getLayer(formData, payload) {
|
||||
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];
|
||||
const data = payload.data.paths.map(path => ({
|
||||
path,
|
||||
let data = payload.data.features.map(feature => ({
|
||||
...feature,
|
||||
path: feature.path,
|
||||
width: fd.line_width,
|
||||
color: fixedColor,
|
||||
}));
|
||||
|
||||
if (fd.js_datapoint_mutator) {
|
||||
const jsFnMutator = sandboxedEval(fd.js_datapoint_mutator);
|
||||
data = data.map(jsFnMutator);
|
||||
}
|
||||
|
||||
return new PathLayer({
|
||||
id: `path-layer-${fd.slice_id}`,
|
||||
data,
|
||||
rounded: true,
|
||||
widthScale: 1,
|
||||
...common.commonLayerProps(fd, slice),
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user