mirror of
https://github.com/apache/superset.git
synced 2026-06-07 16:49:17 +00:00
* Multi layers DECK.GL viz * Fix tests * rebasing * Fix error handling in chartActions * Addressing comments
36 lines
935 B
JavaScript
36 lines
935 B
JavaScript
import { ScatterplotLayer } from 'deck.gl';
|
|
|
|
import { getColorFromScheme, hexToRGB } from '../../../javascripts/modules/colors';
|
|
import { unitToRadius } from '../../../javascripts/modules/geo';
|
|
|
|
export default function getLayer(formData, payload) {
|
|
const fd = formData;
|
|
const c = fd.color_picker || { r: 0, g: 0, b: 0, a: 1 };
|
|
const fixedColor = [c.r, c.g, c.b, 255 * c.a];
|
|
|
|
const data = payload.data.features.map((d) => {
|
|
let radius = unitToRadius(fd.point_unit, d.radius) || 10;
|
|
if (fd.multiplier) {
|
|
radius *= fd.multiplier;
|
|
}
|
|
let color;
|
|
if (fd.dimension) {
|
|
color = hexToRGB(getColorFromScheme(d.cat_color, fd.color_scheme), c.a * 255);
|
|
} else {
|
|
color = fixedColor;
|
|
}
|
|
return {
|
|
...d,
|
|
radius,
|
|
color,
|
|
};
|
|
});
|
|
return new ScatterplotLayer({
|
|
id: `scatter-layer-${fd.slice_id}`,
|
|
data,
|
|
pickable: true,
|
|
fp64: true,
|
|
outline: false,
|
|
});
|
|
}
|