mirror of
https://github.com/apache/superset.git
synced 2026-05-30 12:49:17 +00:00
Filters applied to deck_multi will be passed down to layers as. If the column isn't set as "filterable", the filter is ignored. Also note that Dashboard configuration in regards to "filter_immune_slices" and such will be disregarded in this context as it isn't the dashboard controller passing down the filter and that context is not easily accessible here.
60 lines
1.9 KiB
JavaScript
60 lines
1.9 KiB
JavaScript
import React from 'react';
|
|
import ReactDOM from 'react-dom';
|
|
import $ from 'jquery';
|
|
|
|
import DeckGLContainer from './DeckGLContainer';
|
|
import { getExploreUrl } from '../../javascripts/explore/exploreUtils';
|
|
import layerGenerators from './layers';
|
|
|
|
|
|
function deckMulti(slice, payload, setControlValue) {
|
|
if (!slice.subSlicesLayers) {
|
|
slice.subSlicesLayers = {}; // eslint-disable-line no-param-reassign
|
|
}
|
|
const fd = slice.formData;
|
|
const render = () => {
|
|
const viewport = {
|
|
...fd.viewport,
|
|
width: slice.width(),
|
|
height: slice.height(),
|
|
};
|
|
const layers = Object.keys(slice.subSlicesLayers).map(k => slice.subSlicesLayers[k]);
|
|
ReactDOM.render(
|
|
<DeckGLContainer
|
|
mapboxApiAccessToken={payload.data.mapboxApiKey}
|
|
viewport={viewport}
|
|
layers={layers}
|
|
mapStyle={fd.mapbox_style}
|
|
setControlValue={setControlValue}
|
|
/>,
|
|
document.getElementById(slice.containerId),
|
|
);
|
|
};
|
|
render();
|
|
payload.data.slices.forEach((subslice) => {
|
|
// Filters applied to multi_deck are passed down to underlying charts
|
|
// note that dashboard contextual information (filter_immune_slices and such) aren't
|
|
// taken into consideration here
|
|
let filters = subslice.form_data.filters.concat(fd.filters);
|
|
if (fd.extra_filters) {
|
|
filters = filters.concat(fd.extra_filters);
|
|
}
|
|
const subsliceCopy = {
|
|
...subslice,
|
|
form_data: {
|
|
...subslice.form_data,
|
|
filters,
|
|
},
|
|
};
|
|
|
|
const url = getExploreUrl(subsliceCopy.form_data, 'json');
|
|
$.get(url, (data) => {
|
|
// Late import to avoid circular deps
|
|
const layer = layerGenerators[subsliceCopy.form_data.viz_type](subsliceCopy.form_data, data);
|
|
slice.subSlicesLayers[subsliceCopy.slice_id] = layer; // eslint-disable-line no-param-reassign
|
|
render();
|
|
});
|
|
});
|
|
}
|
|
module.exports = deckMulti;
|