[GitHub] betodealmeida commented on a change in pull request #4336: Play scrubber

2018-02-09 Thread GitBox
betodealmeida commented on a change in pull request #4336: Play scrubber
URL: 
https://github.com/apache/incubator-superset/pull/4336#discussion_r167369652
 
 

 ##
 File path: superset/assets/package.json
 ##
 @@ -69,6 +70,7 @@
 "mapbox-gl": "^0.43.0",
 "mathjs": "^3.16.3",
 "moment": "2.18.1",
+"mousetrap": "^1.6.1",
 
 Review comment:
   Yeah, it's worth doing a PR introducing some basic shortcuts.
   
   At some point I was playing with more shortcuts (left and right to step the 
scrubber, up and down to increase/decrease its width), but I was worried it 
could conflict with other things.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] betodealmeida commented on a change in pull request #4336: Play scrubber

2018-02-09 Thread GitBox
betodealmeida commented on a change in pull request #4336: Play scrubber
URL: 
https://github.com/apache/incubator-superset/pull/4336#discussion_r167369292
 
 

 ##
 File path: superset/assets/visualizations/PlaySlider.css
 ##
 @@ -0,0 +1,21 @@
+.play-slider {
+height: 100px; 
 
 Review comment:
   That's the space currently left in the bottom, below the DeckGL container. 
TBH I wasn't really sure about the best way to place this.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] betodealmeida commented on a change in pull request #4336: Play scrubber

2018-02-09 Thread GitBox
betodealmeida commented on a change in pull request #4336: Play scrubber
URL: 
https://github.com/apache/incubator-superset/pull/4336#discussion_r167369760
 
 

 ##
 File path: superset/assets/visualizations/PlaySlider.jsx
 ##
 @@ -0,0 +1,141 @@
+import React from 'react';
+import PropTypes from 'prop-types';
+
+import Mousetrap from 'mousetrap';
+
+import 'bootstrap-slider/dist/css/bootstrap-slider.min.css';
+import ReactBootstrapSlider from 'react-bootstrap-slider';
+import './PlaySlider.css';
+
+import { t } from '../javascripts/locales';
+
+const propTypes = {
+  start: PropTypes.number.isRequired,
+  step: PropTypes.number.isRequired,
+  end: PropTypes.number.isRequired,
+  values: PropTypes.array.isRequired,
+  onChange: PropTypes.func,
+  loopDuration: PropTypes.number,
+  maxFrames: PropTypes.number,
+  orientation: PropTypes.oneOf(['horizontal', 'vertical']),
+  reversed: PropTypes.bool,
+  disabled: PropTypes.bool,
+};
+
+const defaultProps = {
+  onChange: () => {},
+  loopDuration: 15000,
+  maxFrames: 100,
+  orientation: 'horizontal',
+  reversed: false,
+  disabled: false,
+};
+
+export default class PlaySlider extends React.PureComponent {
+  constructor(props) {
+super(props);
+
+const range = props.end - props.start;
+const frames = Math.min(props.maxFrames, range / props.step);
+const intervalMilliseconds = props.loopDuration / frames;
+const width = range / frames;
+let increment;
+if (width < props.step) {
+  increment = props.step;
+} else {
+  increment = width - (width % props.step);
+}
+
+this.state = { intervalId: null, intervalMilliseconds, increment };
+
+this.onChange = this.onChange.bind(this);
+this.play = this.play.bind(this);
+this.pause = this.pause.bind(this);
+this.step = this.step.bind(this);
+this.getPlayClass = this.getPlayClass.bind(this);
+this.formatter = this.formatter.bind(this);
+  }
+  componentDidMount() {
+Mousetrap.bind(['space'], this.play);
+  }
+  componentWillUnmount() {
+Mousetrap.unbind(['space']);
+  }
+  onChange(event) {
+this.props.onChange({ values: event.target.value });
+if (this.state.intervalId != null) {
+  this.pause();
+}
+  }
+  getPlayClass() {
+if (this.state.intervalId == null) {
+  return 'fa fa-play fa-lg slider-button';
+}
+return 'fa fa-pause fa-lg slider-button';
+  }
+  play() {
+if (this.props.disabled) {
+  return;
+}
+if (this.state.intervalId != null) {
+  this.pause();
+} else {
+  const id = setInterval(this.step, this.state.intervalMilliseconds);
+  this.setState({ intervalId: id });
+}
+  }
+  pause() {
+clearInterval(this.state.intervalId);
+this.setState({ intervalId: null });
+  }
+  step() {
+if (this.props.disabled) {
+  return;
+}
+let values = this.props.values.map(value => value + this.state.increment);
+if (values[1] > this.props.end) {
+  const cr = values[0] - this.props.start;
+  values = values.map(value => value - cr);
+}
+this.props.onChange({ values });
+  }
+  formatter(values) {
+if (this.props.disabled) {
+  return t('Data has no time steps');
+}
+
+let parts = values;
+if (!Array.isArray(values)) {
+  parts = [values];
+} else if (values[0] === values[1]) {
+  parts = [values[0]];
+}
+return parts.map(value => (new Date(value)).toUTCString()).join(' : ');
+  }
+  render() {
+return (
+  
 
 Review comment:
   Cool, I didn't know about them.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] betodealmeida commented on a change in pull request #4336: Play scrubber

2018-02-09 Thread GitBox
betodealmeida commented on a change in pull request #4336: Play scrubber
URL: 
https://github.com/apache/incubator-superset/pull/4336#discussion_r167369777
 
 

 ##
 File path: superset/viz.py
 ##
 @@ -1933,6 +1933,7 @@ class DeckScatterViz(BaseDeckGLViz):
 viz_type = 'deck_scatter'
 verbose_name = _('Deck.gl - Scatter plot')
 spatial_control_keys = ['spatial']
+is_timeseries = True
 
 Review comment:
   Will do.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services