Skip to content
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

Fixes to the play slider #5675

Merged
merged 4 commits into from
Aug 22, 2018
Merged

Fixes to the play slider #5675

merged 4 commits into from
Aug 22, 2018

Conversation

betodealmeida
Copy link
Member

@betodealmeida betodealmeida commented Aug 18, 2018

Some fixes to the CSS:

  • Removed negative bottom position, since the slider was disappearing.
  • Made with smaller so it looks better (see screenshot).
  • Fixed tooltip position that was off-centered to the left.

More importantly, added a props called aggregation to AnimatableDeckGLContainer. When true, the play slider will not allow selecting a wider period than the time granularity. This means that for the scatter plot or GeoJSON visualizations (which show just features) the user can select a wider period and see all the features combined. But for screengrid this doesn't make sense, so it users will be able to only step through the granularity.

screen shot 2018-08-18 at 12 55 45 pm

@codecov-io
Copy link

codecov-io commented Aug 18, 2018

Codecov Report

Merging #5675 into master will decrease coverage by 0.01%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5675      +/-   ##
==========================================
- Coverage   63.49%   63.48%   -0.02%     
==========================================
  Files         360      360              
  Lines       22889    22930      +41     
  Branches     2549     2559      +10     
==========================================
+ Hits        14534    14556      +22     
- Misses       8340     8359      +19     
  Partials       15       15
Impacted Files Coverage Δ
...ts/src/visualizations/deckgl/layers/screengrid.jsx 0% <ø> (ø) ⬆️
...isualizations/deckgl/AnimatableDeckGLContainer.jsx 0% <0%> (ø) ⬆️
superset/assets/src/visualizations/PlaySlider.jsx 0% <0%> (ø) ⬆️
.../assets/src/visualizations/parallel_coordinates.js 0% <0%> (ø) ⬆️
.../assets/src/SqlLab/components/TabbedSqlEditors.jsx 90.99% <0%> (ø) ⬆️
...hboard/components/gridComponents/new/NewHeader.jsx 100% <0%> (ø) ⬆️
...dashboard/components/gridComponents/new/NewRow.jsx 100% <0%> (ø) ⬆️
superset/assets/src/explore/controls.jsx 45.92% <0%> (ø) ⬆️
...hboard/components/gridComponents/new/NewColumn.jsx 100% <0%> (ø) ⬆️
.../assets/src/SqlLab/components/SqlEditorLeftBar.jsx 92.52% <0%> (ø) ⬆️
... and 11 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3d15d91...7f1262b. Read the comment docs.

} else {
values = newValues;
}
this.setState({ values });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Avoid negation if not necessary
this.setState({
  values: Array.isArray(newValues) 
    ? newValues
    : [newValues, newValues + this.props.step]
});

@@ -21,3 +20,7 @@
color: #b3b3b3;
margin-right: 5px;
}

div.tooltip.tooltip-main.top.in {
margin-left: 0 !important;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to override without using !important?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can use a more specific selector, let me take a look.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kristw, the 3rd-party library bootstrap-slider is setting the left margin directly in the DOM using style=, so it overrules any CSS rules. I only got it to work using !important.

@@ -87,7 +89,11 @@ export default class PlaySlider extends React.PureComponent {
if (this.props.disabled) {
return;
}
let values = this.props.values.map(value => value + this.increment);
let values = this.props.values;
if (!Array.isArray(values)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code in if block is not used? Because values is set again right after the block.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good point, will fix.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be confusing if values is the new one or the old one.
I prefer to avoid using let and try not to mutate variable if not necessary.

const { start, end, step, values, disabled } = this.props;
if (disabled) {
  return;
}
const newValues = (Array.isArray(values) ? values : [values, values + step])
  .map(v => v + this.increment);
// What does cr stand for?
const cr = (newValues[1] > end) ? (newValues[0] - start) : 0;
this.props.onChange(cr === 0 ? newValues : newValues.map(v => v - cr));

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CR is carriage return — how much the controls move back once they hit the end of the slider. I'll make the code more clear, thanks!

@@ -46,7 +58,8 @@ export default class AnimatableDeckGLContainer extends React.Component {
end={this.props.end}
step={this.props.step}
values={this.state.values}
onChange={newValues => this.setState({ values: newValues })}
range={!this.props.aggregation}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use deconstruction from this.props to avoid having this.props.xxx multiple time.

const { end, step, aggregation } = this.props;
const { values } = this.state;

@@ -116,7 +122,8 @@ export default class PlaySlider extends React.PureComponent {
</Col>
<Col md={11} className="padded">
<ReactBootstrapSlider
value={this.props.values}
value={this.props.range ? this.props.values : this.props.values[0]}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use deconstruction for this.props

const { range, values } = this.props;

height: 20px;
width: 100%;
width: 90%;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try wrapping PlaySlider in <div style="position: relative">
It will be better to have the slider at full width rather than 90%

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@betodealmeida
Copy link
Member Author

@kristw this is how it looks now:

screen shot 2018-08-21 at 11 55 55 am

@mistercrunch
Copy link
Member

LGTM

1 similar comment
@kristw
Copy link
Contributor

kristw commented Aug 21, 2018

LGTM

@mistercrunch mistercrunch merged commit bcc0954 into apache:master Aug 22, 2018
@mistercrunch mistercrunch deleted the DPTOOLS-942 branch August 22, 2018 04:01
betodealmeida added a commit to lyft/incubator-superset that referenced this pull request Aug 22, 2018
* Fixes to the play slider

* Address comments

* Make CSS rules more strict

* Fix CSS and improve code

(cherry picked from commit bcc0954)
kristw pushed a commit to kristw/incubator-superset that referenced this pull request Aug 27, 2018
* Fixes to the play slider

* Address comments

* Make CSS rules more strict

* Fix CSS and improve code

(cherry picked from commit bcc0954)
wenchma pushed a commit to wenchma/incubator-superset that referenced this pull request Nov 16, 2018
* Fixes to the play slider

* Address comments

* Make CSS rules more strict

* Fix CSS and improve code
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.28.0 labels Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.28.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants