Skip to content

Commit f270a35

Browse files
authored
Merge pull request #811 from plotly/datetimepicker
Datetimepicker
2 parents 6eaca48 + 1c582e8 commit f270a35

File tree

16 files changed

+487
-30
lines changed

16 files changed

+487
-30
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@
1414
"draft-js-utils": "^1.2.0",
1515
"fast-isnumeric": "^1.1.1",
1616
"immutability-helper": "^2.7.1",
17-
"plotly-icons": "1.2.2",
17+
"plotly-icons": "1.2.3",
1818
"plotly.js": "1.43.1",
1919
"prop-types": "^15.5.10",
2020
"raf": "^3.4.0",
2121
"react-color": "^2.13.8",
2222
"react-colorscales": "0.7.2",
23+
"react-day-picker": "^7.2.4",
2324
"react-dropzone": "^5.0.1",
2425
"react-plotly.js": "^2.2.0",
2526
"react-rangeslider": "^2.2.0",

scripts/translationKeys/combined-translation-keys.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ Distributions
221221
Divergence // react-chart-editor: /components/fields/derived.js:597
222222
Diverging // react-chart-editor: /default_panels/StyleLayoutPanel.js:30
223223
Double-click on legend to isolate one trace // plotly.js: components/legend/handle_click.js:89
224-
Double-click to zoom back out // plotly.js: plots/cartesian/dragbox.js:1040
224+
Double-click to zoom back out // plotly.js: plots/cartesian/dragbox.js:1041
225225
Download plot // plotly.js: components/modebar/buttons.js:55
226226
Download plot as a png // plotly.js: components/modebar/buttons.js:54
227227
Drag // react-chart-editor: /default_panels/StyleLayoutPanel.js:90

src/components/fields/AxisRangeValue.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Field from './Field';
22
import {UnconnectedNumeric} from './Numeric';
3-
import {UnconnectedText} from './Text';
3+
import {UnconnectedDateTimePicker} from './DateTimePicker';
44
import PropTypes from 'prop-types';
55
import React, {Component} from 'react';
66
import {connectToContainer} from 'lib';
@@ -9,7 +9,7 @@ export class UnconnectedAxisRangeValue extends Component {
99
render() {
1010
return this.props.multiValued ||
1111
(this.props.fullContainer && this.props.fullContainer.type === 'date') ? (
12-
<UnconnectedText {...this.props} />
12+
<UnconnectedDateTimePicker {...this.props} />
1313
) : (
1414
<UnconnectedNumeric {...this.props} />
1515
);
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import Field from './Field';
2+
import Picker from '../widgets/DateTimePicker';
3+
import PropTypes from 'prop-types';
4+
import React, {Component} from 'react';
5+
import {connectToContainer} from 'lib';
6+
7+
export class UnconnectedDateTimePicker extends Component {
8+
render() {
9+
return (
10+
<Field {...this.props}>
11+
<Picker
12+
value={this.props.fullValue}
13+
placeholder={this.props.placeholder}
14+
onChange={this.props.updatePlot}
15+
/>
16+
</Field>
17+
);
18+
}
19+
}
20+
21+
UnconnectedDateTimePicker.propTypes = {
22+
fullValue: PropTypes.string,
23+
updatePlot: PropTypes.func,
24+
placeholder: PropTypes.string,
25+
...Field.propTypes,
26+
};
27+
28+
export default connectToContainer(UnconnectedDateTimePicker);

src/components/fields/NumericOrDate.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
import Field from './Field';
22
import {UnconnectedNumeric} from './Numeric';
3-
import {UnconnectedText} from './Text';
43
import PropTypes from 'prop-types';
54
import React, {Component} from 'react';
65
import {connectToContainer} from 'lib';
76
import {isDateTime} from 'plotly.js/src/lib';
87
import {isJSDate} from 'plotly.js/src/lib/dates';
8+
import {UnconnectedDateTimePicker} from './DateTimePicker';
99

1010
export class UnconnectedNumericOrDate extends Component {
1111
render() {
12+
const date = typeof this.props.fullValue === 'string' && this.props.fullValue.split(' ')[0];
1213
const fullValueIsDate =
13-
typeof this.props.fullValue === 'string' &&
14-
(isDateTime(this.props.fullValue) || isJSDate(this.props.fullValue));
14+
typeof this.props.fullValue === 'string' && date && (isDateTime(date) || isJSDate(date));
1515

1616
return fullValueIsDate ? (
17-
<UnconnectedText {...this.props} placeholder={'yyyy-mm-dd 00:00:00.00'} />
17+
<UnconnectedDateTimePicker {...this.props} placeholder={'yyyy-mm-dd hh:mm:ss.xxx'} />
1818
) : (
1919
<UnconnectedNumeric {...this.props} />
2020
);

src/components/fields/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ import MultiColorPicker from './MultiColorPicker';
3333
import RectanglePositioner from './RectanglePositioner';
3434
import LocationSelector from './LocationSelector';
3535
import AxisInterval from './AxisInterval';
36+
import DateTimePicker from './DateTimePicker';
37+
3638
import {
3739
AnnotationArrowRef,
3840
AnnotationRef,
@@ -128,4 +130,5 @@ export {
128130
HovermodeDropdown,
129131
AxisInterval,
130132
NumericOrDate,
133+
DateTimePicker,
131134
};

0 commit comments

Comments
 (0)