mirror of
https://github.com/apache/superset.git
synced 2026-06-01 21:59:26 +00:00
* DECKGL integration Adding a new set of geospatial visualizations building on top of the awesome deck.gl library. https://github.com/uber/deck.gl While the end goal it to expose all types of layers and let users bind their data to control most props exposed by the deck.gl API, this PR focusses on a first set of visualizations and props: * ScatterLayer * HexagonLayer * GridLayer * ScreenGridLayer * Addressing comments * lint * Linting * Addressing chri's comments
44 lines
1.2 KiB
JavaScript
44 lines
1.2 KiB
JavaScript
import React from 'react';
|
|
import ReactDOM from 'react-dom';
|
|
import { ScreenGridLayer } from 'deck.gl';
|
|
|
|
import DeckGLContainer from './DeckGLContainer';
|
|
|
|
function deckScreenGridLayer(slice, payload, setControlValue) {
|
|
const fd = slice.formData;
|
|
const c = fd.color_picker;
|
|
const data = payload.data.features.map(d => ({
|
|
...d,
|
|
color: [c.r, c.g, c.b, 255 * c.a],
|
|
}));
|
|
|
|
const viewport = {
|
|
...fd.viewport,
|
|
width: slice.width(),
|
|
height: slice.height(),
|
|
};
|
|
// Passing a layer creator function instead of a layer since the
|
|
// layer needs to be regenerated at each render
|
|
const layer = () => new ScreenGridLayer({
|
|
id: `screengrid-layer-${slice.containerId}`,
|
|
data,
|
|
pickable: true,
|
|
cellSizePixels: fd.grid_size,
|
|
minColor: [c.r, c.g, c.b, 0],
|
|
maxColor: [c.r, c.g, c.b, 255 * c.a],
|
|
outline: false,
|
|
getWeight: d => d.weight || 0,
|
|
});
|
|
ReactDOM.render(
|
|
<DeckGLContainer
|
|
mapboxApiAccessToken={payload.data.mapboxApiKey}
|
|
viewport={viewport}
|
|
layers={[layer]}
|
|
mapStyle={fd.mapbox_style}
|
|
setControlValue={setControlValue}
|
|
/>,
|
|
document.getElementById(slice.containerId),
|
|
);
|
|
}
|
|
module.exports = deckScreenGridLayer;
|