forked from apache/superset
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
ccb87d3
commit bbe3fca
Showing
30 changed files
with
1,277 additions
and
11 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
118 changes: 118 additions & 0 deletions
118
superset/assets/javascripts/explore/components/controls/FixedOrMetricControl.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,118 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Label, Popover, OverlayTrigger } from 'react-bootstrap'; | ||
|
||
import controls from '../../stores/controls'; | ||
import TextControl from './TextControl'; | ||
import SelectControl from './SelectControl'; | ||
import ControlHeader from '../ControlHeader'; | ||
import PopoverSection from '../../../components/PopoverSection'; | ||
|
||
const propTypes = { | ||
onChange: PropTypes.func, | ||
value: PropTypes.object, | ||
isFloat: PropTypes.bool, | ||
datasource: PropTypes.object, | ||
default: PropTypes.object, | ||
}; | ||
|
||
const defaultProps = { | ||
onChange: () => {}, | ||
default: { type: 'fix', value: 5 }, | ||
}; | ||
|
||
export default class FixedOrMetricControl extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.onChange = this.onChange.bind(this); | ||
const type = props.value ? props.value.type : props.default.type || 'fix'; | ||
const value = props.value ? props.value.value : props.default.value || '100'; | ||
this.state = { | ||
type, | ||
fixedValue: type === 'fix' ? value : '', | ||
metricValue: type === 'metric' ? value : null, | ||
}; | ||
} | ||
onChange() { | ||
this.props.onChange({ | ||
type: this.state.type, | ||
value: this.state.type === 'fix' ? this.state.fixedValue : this.state.metricValue, | ||
}); | ||
} | ||
setType(type) { | ||
this.setState({ type }, this.onChange); | ||
} | ||
setFixedValue(fixedValue) { | ||
this.setState({ fixedValue }, this.onChange); | ||
} | ||
setMetric(metricValue) { | ||
this.setState({ metricValue }, this.onChange); | ||
} | ||
renderPopover() { | ||
const value = this.props.value || this.props.default; | ||
const type = value.type || 'fix'; | ||
const metrics = this.props.datasource ? this.props.datasource.metrics : null; | ||
return ( | ||
<Popover id="filter-popover"> | ||
<div style={{ width: '240px' }}> | ||
<PopoverSection | ||
title="Fixed" | ||
isSelected={type === 'fix'} | ||
onSelect={this.onChange.bind(this, 'fix')} | ||
> | ||
<TextControl | ||
isFloat | ||
onChange={this.setFixedValue.bind(this)} | ||
onFocus={this.setType.bind(this, 'fix')} | ||
value={this.state.fixedValue} | ||
/> | ||
</PopoverSection> | ||
<PopoverSection | ||
title="Based on a metric" | ||
isSelected={type === 'metric'} | ||
onSelect={this.onChange.bind(this, 'metric')} | ||
> | ||
<SelectControl | ||
{...controls.metric} | ||
name="metric" | ||
options={metrics} | ||
onFocus={this.setType.bind(this, 'metric')} | ||
onChange={this.setMetric.bind(this)} | ||
value={this.state.metricValue} | ||
/> | ||
</PopoverSection> | ||
</div> | ||
</Popover> | ||
); | ||
} | ||
render() { | ||
return ( | ||
<div> | ||
<ControlHeader {...this.props} /> | ||
<OverlayTrigger | ||
container={document.body} | ||
trigger="click" | ||
rootClose | ||
ref="trigger" | ||
placement="right" | ||
overlay={this.renderPopover()} | ||
> | ||
<Label style={{ cursor: 'pointer' }}> | ||
{this.state.type === 'fix' && | ||
<span>{this.state.fixedValue}</span> | ||
} | ||
{this.state.type === 'metric' && | ||
<span> | ||
<span style={{ fontWeight: 'normal' }}>metric: </span> | ||
<strong>{this.state.metricValue}</strong> | ||
</span> | ||
} | ||
</Label> | ||
</OverlayTrigger> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
FixedOrMetricControl.propTypes = propTypes; | ||
FixedOrMetricControl.defaultProps = defaultProps; |
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
97 changes: 97 additions & 0 deletions
97
superset/assets/javascripts/explore/components/controls/ViewportControl.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,97 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Label, Popover, OverlayTrigger } from 'react-bootstrap'; | ||
import { decimal2sexagesimal } from 'geolib'; | ||
|
||
import TextControl from './TextControl'; | ||
import ControlHeader from '../ControlHeader'; | ||
|
||
const PARAMS = [ | ||
'longitude', | ||
'latitude', | ||
'zoom', | ||
'bearing', | ||
'pitch', | ||
]; | ||
|
||
const propTypes = { | ||
onChange: PropTypes.func.isRequired, | ||
value: PropTypes.object, | ||
default: PropTypes.object, | ||
}; | ||
|
||
const defaultProps = { | ||
onChange: () => {}, | ||
default: { type: 'fix', value: 5 }, | ||
value: { | ||
longitude: 6.85236157047845, | ||
latitude: 31.222656842808707, | ||
zoom: 1, | ||
bearing: 0, | ||
pitch: 0, | ||
}, | ||
}; | ||
|
||
export default class ViewportControl extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.onChange = this.onChange.bind(this); | ||
} | ||
onChange(ctrl, value) { | ||
this.props.onChange({ | ||
...this.props.value, | ||
[ctrl]: value, | ||
}); | ||
} | ||
renderTextControl(ctrl) { | ||
return ( | ||
<div> | ||
{ctrl} | ||
<TextControl | ||
value={this.props.value[ctrl]} | ||
onChange={this.onChange.bind(this, ctrl)} | ||
isFloat | ||
/> | ||
</div> | ||
); | ||
} | ||
renderPopover() { | ||
return ( | ||
<Popover id="filter-popover" title="Viewport"> | ||
{PARAMS.map(ctrl => this.renderTextControl(ctrl))} | ||
</Popover> | ||
); | ||
} | ||
renderLabel() { | ||
if (this.props.value.longitude && this.props.value.latitude) { | ||
return ( | ||
decimal2sexagesimal(this.props.value.longitude) + | ||
' | ' + | ||
decimal2sexagesimal(this.props.value.latitude) | ||
); | ||
} | ||
return 'N/A'; | ||
} | ||
render() { | ||
return ( | ||
<div> | ||
<ControlHeader {...this.props} /> | ||
<OverlayTrigger | ||
container={document.body} | ||
trigger="click" | ||
rootClose | ||
ref="trigger" | ||
placement="right" | ||
overlay={this.renderPopover()} | ||
> | ||
<Label style={{ cursor: 'pointer' }}> | ||
{this.renderLabel()} | ||
</Label> | ||
</OverlayTrigger> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
ViewportControl.propTypes = propTypes; | ||
ViewportControl.defaultProps = defaultProps; |
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.