Skip to content

Commit 3727c27

Browse files
authored
Merge pull request #660 from plotly/geo-fixes
Geo fixes
2 parents 6c596fc + f2fe6de commit 3727c27

File tree

14 files changed

+265
-166
lines changed

14 files changed

+265
-166
lines changed

src/EditorControls.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ class EditorControls extends Component {
2020
constructor(props, context) {
2121
super(props, context);
2222

23+
this.localize = key =>
24+
localizeString(this.props.dictionaries || {}, this.props.locale, key);
25+
2326
// we only need to compute this once.
2427
if (this.props.plotly) {
2528
this.plotSchema = this.props.plotly.PlotSchema.get();
@@ -38,8 +41,7 @@ class EditorControls extends Component {
3841
dataSourceValueRenderer: this.props.dataSourceValueRenderer,
3942
dataSourceOptionRenderer: this.props.dataSourceOptionRenderer,
4043
dictionaries: this.props.dictionaries || {},
41-
localize: key =>
42-
localizeString(this.props.dictionaries || {}, this.props.locale, key),
44+
localize: this.localize,
4345
frames: gd._transitionData ? gd._transitionData._frames : [],
4446
fullData: gd._fullData,
4547
fullLayout: gd._fullLayout,
@@ -281,7 +283,9 @@ class EditorControls extends Component {
281283
break;
282284

283285
default:
284-
throw new Error('must specify an action type to handleEditorUpdate');
286+
throw new Error(
287+
this.localize('must specify an action type to handleEditorUpdate')
288+
);
285289
}
286290
}
287291

src/components/containers/ModalProvider.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,17 @@ class ModalProvider extends React.Component {
2727
}
2828
}
2929

30-
openModal(component, props) {
30+
openModal(component, componentProps) {
31+
const {localize: _} = this.context;
3132
if (!component) {
32-
throw Error('You need to provide a component for the modal to open!');
33+
throw Error(_('You need to provide a component for the modal to open!'));
3334
}
3435
const {open} = this.state;
3536

3637
if (!open) {
3738
this.setState({
3839
component: component,
39-
componentProps: props,
40+
componentProps: componentProps,
4041
open: true,
4142
});
4243
}
@@ -85,6 +86,9 @@ class ModalProvider extends React.Component {
8586
ModalProvider.propTypes = {
8687
children: PropTypes.node,
8788
};
89+
ModalProvider.contextTypes = {
90+
localize: PropTypes.func,
91+
};
8892
ModalProvider.childContextTypes = {
8993
openModal: PropTypes.func,
9094
closeModal: PropTypes.func,

src/components/containers/TraceAccordion.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import React, {Component} from 'react';
66
import {EDITOR_ACTIONS} from 'lib/constants';
77
import {connectTraceToPlot, plotlyTraceToCustomTrace} from 'lib';
88
import {Tab, Tabs, TabList, TabPanel} from 'react-tabs';
9+
import {traceTypes} from 'lib/traceTypes';
910

1011
const TraceFold = connectTraceToPlot(PlotlyFold);
1112

@@ -38,6 +39,7 @@ class TraceAccordion extends Component {
3839
return null;
3940
}
4041

42+
const {localize: _} = this.context;
4143
const dataArrayPositionsByTraceType = {};
4244
const fullDataArrayPositionsByTraceType = {};
4345

@@ -62,7 +64,7 @@ class TraceAccordion extends Component {
6264
<TraceFold
6365
key={index}
6466
traceIndexes={dataArrayPositionsByTraceType[type]}
65-
name={type}
67+
name={traceTypes(_).find(t => t.value === type).label}
6668
fullDataArrayPosition={fullDataArrayPositionsByTraceType[type]}
6769
>
6870
{this.props.children}

src/components/fields/AxesCreator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ class UnconnectedAxesCreator extends Component {
154154
<AxisCreator
155155
key={index}
156156
attr={type}
157-
label={type.charAt(0).toUpperCase() + ' Axis'}
157+
label={type.charAt(0).toUpperCase() + _(' Axis')}
158158
options={getOptions(type)}
159159
/>
160160
);

src/components/fields/AxesSelector.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ import React, {Component} from 'react';
77
class AxesSelector extends Component {
88
constructor(props, context) {
99
super(props, context);
10+
const {localize: _} = context;
1011

1112
if (!context.axesTargetHandler) {
1213
throw new Error(
13-
'AxesSelector must be nested within a connectAxesToPlot component'
14+
_('AxesSelector must be nested within a connectAxesToPlot component')
1415
);
1516
}
1617
}

src/components/fields/FilterOperation.js

Lines changed: 60 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -5,60 +5,38 @@ import DropdownWidget from '../widgets/Dropdown';
55
import TextInput from '../widgets/TextInput';
66
import {connectToContainer} from 'lib';
77

8-
const operators = [
9-
{
10-
label: 'Inequality',
11-
value: 'inequality',
12-
},
13-
{
14-
label: 'Include Range',
15-
value: 'inrange',
16-
},
17-
{
18-
label: 'Exclude Range',
19-
value: 'exrange',
20-
},
21-
{
22-
label: 'Include Values',
23-
value: 'inset',
24-
},
25-
{
26-
label: 'Exclude Values',
27-
value: 'exset',
28-
},
29-
];
30-
31-
const operations = {
8+
const operations = _ => ({
329
inequality: [
33-
{value: '!=', label: 'Target ≠ Reference'},
34-
{value: '<', label: 'Target < Reference'},
35-
{value: '<=', label: 'Target ≤ Reference'},
36-
{value: '=', label: 'Target = Reference'},
37-
{value: '>', label: 'Target > Reference'},
38-
{value: '>=', label: 'Target ≥ Reference'},
10+
{value: '!=', label: _('Target ≠ Reference')},
11+
{value: '<', label: _('Target < Reference')},
12+
{value: '<=', label: _('Target ≤ Reference')},
13+
{value: '=', label: _('Target = Reference')},
14+
{value: '>', label: _('Target > Reference')},
15+
{value: '>=', label: _('Target ≥ Reference')},
3916
],
4017
inrange: [
41-
{value: '[]', label: 'Lower ≤ Target ≤ Upper'},
42-
{value: '()', label: 'Lower < Target < Upper'},
43-
{value: '[)', label: 'Lower ≤ Target < Upper'},
44-
{value: '(]', label: 'Lower < Target ≤ Upper'},
18+
{value: '[]', label: _('Lower ≤ Target ≤ Upper')},
19+
{value: '()', label: _('Lower < Target < Upper')},
20+
{value: '[)', label: _('Lower ≤ Target < Upper')},
21+
{value: '(]', label: _('Lower < Target ≤ Upper')},
4522
],
4623
exrange: [
47-
{value: ')(', label: 'Lower ≤ Target ≤ Upper'},
48-
{value: '][', label: 'Lower < Target < Upper'},
49-
{value: ')[', label: 'Lower ≤ Target < Upper'},
50-
{value: '](', label: 'Lower < Target ≤ Upper'},
24+
{value: ')(', label: _('Lower ≤ Target ≤ Upper')},
25+
{value: '][', label: _('Lower < Target < Upper')},
26+
{value: ')[', label: _('Lower ≤ Target < Upper')},
27+
{value: '](', label: _('Lower < Target ≤ Upper')},
5128
],
52-
inset: [{value: '{}', label: 'Include'}],
53-
exset: [{value: '}{', label: 'Exclude'}],
54-
};
29+
inset: [{value: '{}', label: _('Include')}],
30+
exset: [{value: '}{', label: _('Exclude')}],
31+
});
5532

56-
const findOperation = operator => {
33+
const findOperation = (operator, _) => {
5734
let op = 'inequality';
58-
for (const key in operations) {
35+
const ops = operations(_);
36+
for (const key in ops) {
5937
if (
60-
operations.hasOwnProperty(key) &&
61-
operations[key].map(o => o.value).indexOf(operator) !== -1
38+
ops.hasOwnProperty(key) &&
39+
ops[key].map(o => o.value).indexOf(operator) !== -1
6240
) {
6341
op = key;
6442
break;
@@ -70,17 +48,19 @@ const findOperation = operator => {
7048
class UnconnectedFilterOperation extends Component {
7149
constructor(props, context) {
7250
super(props, context);
51+
const {localize: _} = context;
7352

7453
this.state = {
75-
operation: findOperation(this.props.fullValue),
76-
operator: operations.inequality[0].value,
54+
operation: findOperation(this.props.fullValue, _),
55+
operator: operations(_).inequality[0].value,
7756
};
7857

7958
this.setOperation = this.setOperation.bind(this);
8059
}
8160

8261
setOperation(value) {
83-
const operator = operations[value][0].value;
62+
const {localize: _} = this.context;
63+
const operator = operations(_)[value][0].value;
8464
this.setState({operation: value, operator: operator});
8565
this.props.updatePlot(operator);
8666
}
@@ -94,6 +74,30 @@ class UnconnectedFilterOperation extends Component {
9474
backgroundDark,
9575
attr,
9676
} = this.props;
77+
const {localize: _} = this.context;
78+
79+
const operators = [
80+
{
81+
label: _('Inequality'),
82+
value: 'inequality',
83+
},
84+
{
85+
label: _('Include Range'),
86+
value: 'inrange',
87+
},
88+
{
89+
label: _('Exclude Range'),
90+
value: 'exrange',
91+
},
92+
{
93+
label: _('Include Values'),
94+
value: 'inset',
95+
},
96+
{
97+
label: _('Exclude Values'),
98+
value: 'exset',
99+
},
100+
];
97101

98102
const opValue =
99103
fullValue && fullValue.length > 0 ? fullValue : this.state.operator;
@@ -103,7 +107,7 @@ class UnconnectedFilterOperation extends Component {
103107
<DropdownWidget
104108
backgroundDark={backgroundDark}
105109
options={operators}
106-
value={findOperation(opValue)}
110+
value={findOperation(opValue, _)}
107111
onChange={this.setOperation}
108112
clearable={false}
109113
optionRenderer={optionRenderer}
@@ -113,7 +117,7 @@ class UnconnectedFilterOperation extends Component {
113117
this.state.operation === 'exset' ? null : (
114118
<DropdownWidget
115119
backgroundDark={backgroundDark}
116-
options={operations[this.state.operation]}
120+
options={operations(_)[this.state.operation]}
117121
value={opValue}
118122
onChange={updatePlot}
119123
clearable={false}
@@ -132,6 +136,9 @@ UnconnectedFilterOperation.propTypes = {
132136
updatePlot: PropTypes.func,
133137
...Field.propTypes,
134138
};
139+
UnconnectedFilterOperation.contextTypes = {
140+
localize: PropTypes.func,
141+
};
135142

136143
class UnconnectedFilterValue extends Component {
137144
constructor(props, context) {
@@ -144,7 +151,8 @@ class UnconnectedFilterValue extends Component {
144151
}
145152

146153
setValue(v) {
147-
const op = findOperation(this.context.container.operation);
154+
const {localize: _, container} = this.context;
155+
const op = findOperation(container.operation, _);
148156
this.setState({value: v});
149157
let val;
150158
val = op === 'inrange' || op === 'exrange' ? [v, this.state.valueMax] : v;
@@ -167,7 +175,7 @@ class UnconnectedFilterValue extends Component {
167175
container && container.operation ? container.operation : '=';
168176

169177
const {fullValue, attr, defaultValue} = this.props;
170-
const op = findOperation(operation);
178+
const op = findOperation(operation, _);
171179

172180
let label1 = _('Reference');
173181
if (op === 'inrange' || op === 'exrange') {

src/components/fields/MarkerColor.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class UnconnectedMarkerColor extends Component {
5757
this.context.updateContainer({
5858
['marker.colorsrc']: null,
5959
['marker.colorscale']: null,
60+
['marker.showscale']: null,
6061
});
6162
this.setState({colorscale: null});
6263
} else {

0 commit comments

Comments
 (0)