-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SIP-5] Remove references to slice from all deck.gl components. (#6039)
* start removing slice. * migrate arc * refactor arc * refactor path * refactor deck polygon * remove commented code * refactor factory function * refactor grid * refactor hex * refactor polygon * refactor scatter * refactor geojson * refactor screengrid * remove unnecessary nesting * add proptypes * add proptypes * refactor deck.gl Multi * fix lint * Use export syntax instead of module.exports
- Loading branch information
1 parent
5282f39
commit 2a7b64f
Showing
14 changed files
with
312 additions
and
347 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
superset/assets/src/visualizations/deckgl/createAdaptor.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
|
||
const IDENTITY = x => x; | ||
|
||
class DeckGlChartInput { | ||
constructor(slice, payload, setControlValue) { | ||
this.formData = slice.formData; | ||
this.payload = payload; | ||
this.setControlValue = setControlValue; | ||
this.viewport = { | ||
...this.formData.viewport, | ||
width: slice.width(), | ||
height: slice.height(), | ||
}; | ||
|
||
this.onAddFilter = ((...args) => { slice.addFilter(...args); }); | ||
this.onTooltip = ((...args) => { slice.tooltip(...args); }); | ||
} | ||
} | ||
|
||
export default function createAdaptor(Component, transformProps = IDENTITY) { | ||
return function adaptor(slice, payload, setControlValue) { | ||
const chartInput = new DeckGlChartInput(slice, payload, setControlValue); | ||
ReactDOM.render( | ||
<Component {...transformProps(chartInput)} />, | ||
document.querySelector(slice.selector), | ||
); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import DeckGLContainer from './DeckGLContainer'; | ||
import CategoricalDeckGLContainer from './CategoricalDeckGLContainer'; | ||
import { fitViewport } from './layers/common'; | ||
|
||
const propTypes = { | ||
formData: PropTypes.object.isRequired, | ||
payload: PropTypes.object.isRequired, | ||
setControlValue: PropTypes.func.isRequired, | ||
viewport: PropTypes.object.isRequired, | ||
onAddFilter: PropTypes.func, | ||
onTooltip: PropTypes.func, | ||
}; | ||
const defaultProps = { | ||
onAddFilter() {}, | ||
onTooltip() {}, | ||
}; | ||
|
||
export function createDeckGLComponent(getLayer, getPoints) { | ||
function Component(props) { | ||
const { | ||
formData, | ||
payload, | ||
setControlValue, | ||
onAddFilter, | ||
onTooltip, | ||
viewport: originalViewport, | ||
} = props; | ||
|
||
const viewport = formData.autozoom | ||
? fitViewport(originalViewport, getPoints(payload.data.features)) | ||
: originalViewport; | ||
|
||
const layer = getLayer(formData, payload, onAddFilter, onTooltip); | ||
|
||
return ( | ||
<DeckGLContainer | ||
mapboxApiAccessToken={payload.data.mapboxApiKey} | ||
viewport={viewport} | ||
layers={[layer]} | ||
mapStyle={formData.mapbox_style} | ||
setControlValue={setControlValue} | ||
/> | ||
); | ||
} | ||
|
||
Component.propTypes = propTypes; | ||
Component.defaultProps = defaultProps; | ||
|
||
return Component; | ||
} | ||
|
||
export function createCategoricalDeckGLComponent(getLayer, getPoints) { | ||
function Component(props) { | ||
const { | ||
formData, | ||
payload, | ||
setControlValue, | ||
onAddFilter, | ||
onTooltip, | ||
viewport: originalViewport, | ||
} = props; | ||
|
||
const viewport = formData.autozoom | ||
? fitViewport(originalViewport, getPoints(payload.data.features)) | ||
: originalViewport; | ||
|
||
return ( | ||
<CategoricalDeckGLContainer | ||
formData={formData} | ||
mapboxApiKey={payload.data.mapboxApiKey} | ||
setControlValue={setControlValue} | ||
viewport={viewport} | ||
getLayer={getLayer} | ||
payload={payload} | ||
onAddFilter={onAddFilter} | ||
onTooltip={onTooltip} | ||
/> | ||
); | ||
} | ||
|
||
Component.propTypes = propTypes; | ||
Component.defaultProps = defaultProps; | ||
|
||
return Component; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.