-
Notifications
You must be signed in to change notification settings - Fork 14.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[deck polygon] add support for geohash #5712
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.BootstrapSliderWrapper .slider-selection { | ||
background: #efefef; | ||
} | ||
|
||
.BootstrapSliderWrapper .slider-handle { | ||
background: #b3b3b3; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import React from 'react'; | ||
import ReactBootstrapSlider from 'react-bootstrap-slider'; | ||
import 'bootstrap-slider/dist/css/bootstrap-slider.min.css'; | ||
import './BootstrapSliderWrapper.css'; | ||
|
||
export default function BootstrapSliderWrapper(props) { | ||
return ( | ||
<span className="BootstrapSliderWrapper"> | ||
<ReactBootstrapSlider {...props} /> | ||
</span> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
import BootstrapSliderWrapper from '../../../components/BootstrapSliderWrapper'; | ||
import ControlHeader from '../ControlHeader'; | ||
|
||
const propTypes = { | ||
onChange: PropTypes.func, | ||
value: PropTypes.oneOfType([ | ||
PropTypes.string, | ||
PropTypes.number, | ||
]), | ||
}; | ||
|
||
const defaultProps = { | ||
onChange: () => {}, | ||
}; | ||
|
||
export default function SliderControl(props) { | ||
// This wouldn't be necessary but might as well | ||
return ( | ||
<div> | ||
<ControlHeader {...props} /> | ||
<BootstrapSliderWrapper | ||
{...props} | ||
change={(obj) => { | ||
props.onChange(obj.target.value); | ||
}} | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
SliderControl.propTypes = propTypes; | ||
SliderControl.defaultProps = defaultProps; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -525,6 +525,16 @@ export const spectrums = { | |
], | ||
}; | ||
|
||
export function hexToRGB(hex, alpha = 255) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @hughhhh already imports There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh ere I only move the code from lower in the file since my linter was complaining about "referenced before defined". Though I don't want to sign up for it in the scope of this, PR, I totally agree that we should leverage d3-color as much as possible. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it. I am fine with leaving it for later refactor outside of this PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes actually I'm realizing that there's a need here for replacing whites with transparency for maps. That never was an issue with white backgrounds, but these maps would look better with transparency in place of whites. This calls for more of a refactor of these color gradients. We're also thinking about improving the control itself, allowing for user choosing colors and bounds, and maybe something about quantiles/ranking. |
||
if (!hex) { | ||
return [0, 0, 0, alpha]; | ||
} | ||
const r = parseInt(hex.slice(1, 3), 16); | ||
const g = parseInt(hex.slice(3, 5), 16); | ||
const b = parseInt(hex.slice(5, 7), 16); | ||
return [r, g, b, alpha]; | ||
} | ||
|
||
/** | ||
* Get a color from a scheme specific palette (scheme) | ||
* The function cycles through the palette while memoizing labels | ||
|
@@ -566,7 +576,7 @@ export const getColorFromScheme = (function () { | |
}; | ||
}()); | ||
|
||
export const colorScalerFactory = function (colors, data, accessor, extents) { | ||
export const colorScalerFactory = function (colors, data, accessor, extents, outputRGBA = false) { | ||
// Returns a linear scaler our of an array of color | ||
if (!Array.isArray(colors)) { | ||
/* eslint no-param-reassign: 0 */ | ||
|
@@ -581,15 +591,9 @@ export const colorScalerFactory = function (colors, data, accessor, extents) { | |
} | ||
const chunkSize = (ext[1] - ext[0]) / (colors.length - 1); | ||
const points = colors.map((col, i) => ext[0] + (i * chunkSize)); | ||
return d3.scale.linear().domain(points).range(colors).clamp(true); | ||
}; | ||
|
||
export function hexToRGB(hex, alpha = 255) { | ||
if (!hex) { | ||
return [0, 0, 0, alpha]; | ||
const scaler = d3.scale.linear().domain(points).range(colors).clamp(true); | ||
if (outputRGBA) { | ||
return v => hexToRGB(scaler(v)); | ||
} | ||
const r = parseInt(hex.slice(1, 3), 16); | ||
const g = parseInt(hex.slice(3, 5), 16); | ||
const b = parseInt(hex.slice(5, 7), 16); | ||
return [r, g, b, alpha]; | ||
} | ||
return scaler; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,7 @@ import { Row, Col } from 'react-bootstrap'; | |
|
||
import Mousetrap from 'mousetrap'; | ||
|
||
import 'bootstrap-slider/dist/css/bootstrap-slider.min.css'; | ||
import ReactBootstrapSlider from 'react-bootstrap-slider'; | ||
import './PlaySlider.css'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This import should still be here, since it has more styles than were moved to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch! |
||
import BootrapSliderWrapper from '../components/BootstrapSliderWrapper'; | ||
|
||
import { t } from '../locales'; | ||
|
||
|
@@ -120,7 +118,7 @@ export default class PlaySlider extends React.PureComponent { | |
<i className="fa fa-step-forward fa-lg slider-button " onClick={this.step} /> | ||
</Col> | ||
<Col md={11} className="padded"> | ||
<ReactBootstrapSlider | ||
<BootrapSliderWrapper | ||
value={range ? values : values[0]} | ||
range={range} | ||
formatter={this.formatter} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,14 +7,15 @@ import 'mapbox-gl/dist/mapbox-gl.css'; | |
const propTypes = { | ||
viewport: PropTypes.object.isRequired, | ||
layers: PropTypes.array.isRequired, | ||
setControlValue: PropTypes.func.isRequired, | ||
setControlValue: PropTypes.func, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, this was annoying. |
||
mapStyle: PropTypes.string, | ||
mapboxApiAccessToken: PropTypes.string.isRequired, | ||
onViewportChange: PropTypes.func, | ||
}; | ||
const defaultProps = { | ||
mapStyle: 'light', | ||
onViewportChange: () => {}, | ||
setControlValue: () => {}, | ||
}; | ||
|
||
export default class DeckGLContainer extends React.Component { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: "...between 0 and 100"