Skip to content

Commit abbb67d

Browse files
authored
Merge pull request #2341 from plotly/react
Plotly.react
2 parents ef2bff1 + 5d6a4a0 commit abbb67d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+1433
-527
lines changed

Diff for: devtools/test_dashboard/devtools.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ function searchMocks(e) {
202202

203203
results.forEach(function(r) {
204204
var result = document.createElement('span');
205-
result.className = 'search-result';
205+
result.className = getResultClass(r.name);
206206
result.innerText = r.name;
207207

208208
result.addEventListener('click', function() {
@@ -212,6 +212,10 @@ function searchMocks(e) {
212212
// Clear plots and plot selected.
213213
Tabs.purge();
214214
Tabs.plotMock(mockName);
215+
216+
mocksList.querySelectorAll('span').forEach(function(el) {
217+
el.className = getResultClass(el.innerText);
218+
});
215219
});
216220

217221
mocksList.appendChild(result);
@@ -222,8 +226,16 @@ function searchMocks(e) {
222226
});
223227
}
224228

229+
function getNameFromHash() {
230+
return window.location.hash.replace(/^#/, '');
231+
}
232+
233+
function getResultClass(name) {
234+
return 'search-result' + (getNameFromHash() === name ? ' search-result__selected' : '');
235+
}
236+
225237
function plotFromHash() {
226-
var initialMock = window.location.hash.replace(/^#/, '');
238+
var initialMock = getNameFromHash();
227239

228240
if(initialMock.length > 0) {
229241
Tabs.plotMock(initialMock);

Diff for: devtools/test_dashboard/style.css

+3
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ header span{
5656
color: #fff;
5757
background-color: #4983EC;
5858
}
59+
.search-result__selected{
60+
background-color: #DDDDEE;
61+
}
5962
#plots{
6063
overflow: scroll;
6164
}

Diff for: src/components/annotations/attributes.js

+22-22
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module.exports = {
2020
valType: 'boolean',
2121
role: 'info',
2222
dflt: true,
23-
editType: 'calcIfAutorange',
23+
editType: 'calcIfAutorange+arraydraw',
2424
description: [
2525
'Determines whether or not this annotation is visible.'
2626
].join(' ')
@@ -29,7 +29,7 @@ module.exports = {
2929
text: {
3030
valType: 'string',
3131
role: 'info',
32-
editType: 'calcIfAutorange',
32+
editType: 'calcIfAutorange+arraydraw',
3333
description: [
3434
'Sets the text associated with this annotation.',
3535
'Plotly uses a subset of HTML tags to do things like',
@@ -42,14 +42,14 @@ module.exports = {
4242
valType: 'angle',
4343
dflt: 0,
4444
role: 'style',
45-
editType: 'calcIfAutorange',
45+
editType: 'calcIfAutorange+arraydraw',
4646
description: [
4747
'Sets the angle at which the `text` is drawn',
4848
'with respect to the horizontal.'
4949
].join(' ')
5050
},
5151
font: fontAttrs({
52-
editType: 'calcIfAutorange',
52+
editType: 'calcIfAutorange+arraydraw',
5353
colorEditType: 'arraydraw',
5454
description: 'Sets the annotation text font.'
5555
}),
@@ -58,7 +58,7 @@ module.exports = {
5858
min: 1,
5959
dflt: null,
6060
role: 'style',
61-
editType: 'calcIfAutorange',
61+
editType: 'calcIfAutorange+arraydraw',
6262
description: [
6363
'Sets an explicit width for the text box. null (default) lets the',
6464
'text set the box width. Wider text will be clipped.',
@@ -70,7 +70,7 @@ module.exports = {
7070
min: 1,
7171
dflt: null,
7272
role: 'style',
73-
editType: 'calcIfAutorange',
73+
editType: 'calcIfAutorange+arraydraw',
7474
description: [
7575
'Sets an explicit height for the text box. null (default) lets the',
7676
'text set the box height. Taller text will be clipped.'
@@ -131,7 +131,7 @@ module.exports = {
131131
min: 0,
132132
dflt: 1,
133133
role: 'style',
134-
editType: 'calcIfAutorange',
134+
editType: 'calcIfAutorange+arraydraw',
135135
description: [
136136
'Sets the padding (in px) between the `text`',
137137
'and the enclosing border.'
@@ -142,7 +142,7 @@ module.exports = {
142142
min: 0,
143143
dflt: 1,
144144
role: 'style',
145-
editType: 'calcIfAutorange',
145+
editType: 'calcIfAutorange+arraydraw',
146146
description: [
147147
'Sets the width (in px) of the border enclosing',
148148
'the annotation `text`.'
@@ -153,7 +153,7 @@ module.exports = {
153153
valType: 'boolean',
154154
dflt: true,
155155
role: 'style',
156-
editType: 'calcIfAutorange',
156+
editType: 'calcIfAutorange+arraydraw',
157157
description: [
158158
'Determines whether or not the annotation is drawn with an arrow.',
159159
'If *true*, `text` is placed near the arrow\'s tail.',
@@ -198,7 +198,7 @@ module.exports = {
198198
min: 0.3,
199199
dflt: 1,
200200
role: 'style',
201-
editType: 'calcIfAutorange',
201+
editType: 'calcIfAutorange+arraydraw',
202202
description: [
203203
'Sets the size of the end annotation arrow head, relative to `arrowwidth`.',
204204
'A value of 1 (default) gives a head about 3x as wide as the line.'
@@ -209,7 +209,7 @@ module.exports = {
209209
min: 0.3,
210210
dflt: 1,
211211
role: 'style',
212-
editType: 'calcIfAutorange',
212+
editType: 'calcIfAutorange+arraydraw',
213213
description: [
214214
'Sets the size of the start annotation arrow head, relative to `arrowwidth`.',
215215
'A value of 1 (default) gives a head about 3x as wide as the line.'
@@ -219,15 +219,15 @@ module.exports = {
219219
valType: 'number',
220220
min: 0.1,
221221
role: 'style',
222-
editType: 'calcIfAutorange',
222+
editType: 'calcIfAutorange+arraydraw',
223223
description: 'Sets the width (in px) of annotation arrow line.'
224224
},
225225
standoff: {
226226
valType: 'number',
227227
min: 0,
228228
dflt: 0,
229229
role: 'style',
230-
editType: 'calcIfAutorange',
230+
editType: 'calcIfAutorange+arraydraw',
231231
description: [
232232
'Sets a distance, in pixels, to move the end arrowhead away from the',
233233
'position it is pointing at, for example to point at the edge of',
@@ -241,7 +241,7 @@ module.exports = {
241241
min: 0,
242242
dflt: 0,
243243
role: 'style',
244-
editType: 'calcIfAutorange',
244+
editType: 'calcIfAutorange+arraydraw',
245245
description: [
246246
'Sets a distance, in pixels, to move the start arrowhead away from the',
247247
'position it is pointing at, for example to point at the edge of',
@@ -253,7 +253,7 @@ module.exports = {
253253
ax: {
254254
valType: 'any',
255255
role: 'info',
256-
editType: 'calcIfAutorange',
256+
editType: 'calcIfAutorange+arraydraw',
257257
description: [
258258
'Sets the x component of the arrow tail about the arrow head.',
259259
'If `axref` is `pixel`, a positive (negative) ',
@@ -266,7 +266,7 @@ module.exports = {
266266
ay: {
267267
valType: 'any',
268268
role: 'info',
269-
editType: 'calcIfAutorange',
269+
editType: 'calcIfAutorange+arraydraw',
270270
description: [
271271
'Sets the y component of the arrow tail about the arrow head.',
272272
'If `ayref` is `pixel`, a positive (negative) ',
@@ -333,7 +333,7 @@ module.exports = {
333333
x: {
334334
valType: 'any',
335335
role: 'info',
336-
editType: 'calcIfAutorange',
336+
editType: 'calcIfAutorange+arraydraw',
337337
description: [
338338
'Sets the annotation\'s x position.',
339339
'If the axis `type` is *log*, then you must take the',
@@ -351,7 +351,7 @@ module.exports = {
351351
values: ['auto', 'left', 'center', 'right'],
352352
dflt: 'auto',
353353
role: 'info',
354-
editType: 'calcIfAutorange',
354+
editType: 'calcIfAutorange+arraydraw',
355355
description: [
356356
'Sets the text box\'s horizontal position anchor',
357357
'This anchor binds the `x` position to the *left*, *center*',
@@ -370,7 +370,7 @@ module.exports = {
370370
valType: 'number',
371371
dflt: 0,
372372
role: 'style',
373-
editType: 'calcIfAutorange',
373+
editType: 'calcIfAutorange+arraydraw',
374374
description: [
375375
'Shifts the position of the whole annotation and arrow to the',
376376
'right (positive) or left (negative) by this many pixels.'
@@ -396,7 +396,7 @@ module.exports = {
396396
y: {
397397
valType: 'any',
398398
role: 'info',
399-
editType: 'calcIfAutorange',
399+
editType: 'calcIfAutorange+arraydraw',
400400
description: [
401401
'Sets the annotation\'s y position.',
402402
'If the axis `type` is *log*, then you must take the',
@@ -414,7 +414,7 @@ module.exports = {
414414
values: ['auto', 'top', 'middle', 'bottom'],
415415
dflt: 'auto',
416416
role: 'info',
417-
editType: 'calcIfAutorange',
417+
editType: 'calcIfAutorange+arraydraw',
418418
description: [
419419
'Sets the text box\'s vertical position anchor',
420420
'This anchor binds the `y` position to the *top*, *middle*',
@@ -433,7 +433,7 @@ module.exports = {
433433
valType: 'number',
434434
dflt: 0,
435435
role: 'style',
436-
editType: 'calcIfAutorange',
436+
editType: 'calcIfAutorange+arraydraw',
437437
description: [
438438
'Shifts the position of the whole annotation and arrow up',
439439
'(positive) or down (negative) by this many pixels.'

Diff for: src/components/annotations3d/convert.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ function mockAnnAxes(ann, scene) {
5050
Axes.setConvert(ann._xa);
5151
ann._xa._offset = size.l + domain.x[0] * size.w;
5252
ann._xa.l2p = function() {
53-
return 0.5 * (1 + ann.pdata[0] / ann.pdata[3]) * size.w * (domain.x[1] - domain.x[0]);
53+
return 0.5 * (1 + ann._pdata[0] / ann._pdata[3]) * size.w * (domain.x[1] - domain.x[0]);
5454
};
5555

5656
ann._ya = {};
5757
Lib.extendFlat(ann._ya, base);
5858
Axes.setConvert(ann._ya);
5959
ann._ya._offset = size.t + (1 - domain.y[1]) * size.h;
6060
ann._ya.l2p = function() {
61-
return 0.5 * (1 - ann.pdata[1] / ann.pdata[3]) * size.h * (domain.y[1] - domain.y[0]);
61+
return 0.5 * (1 - ann._pdata[1] / ann._pdata[3]) * size.h * (domain.y[1] - domain.y[0]);
6262
};
6363
}

Diff for: src/components/annotations3d/draw.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ module.exports = function draw(scene) {
3838
.select('.annotation-' + scene.id + '[data-index="' + i + '"]')
3939
.remove();
4040
} else {
41-
ann.pdata = project(scene.glplot.cameraParams, [
41+
ann._pdata = project(scene.glplot.cameraParams, [
4242
fullSceneLayout.xaxis.r2l(ann.x) * dataScale[0],
4343
fullSceneLayout.yaxis.r2l(ann.y) * dataScale[1],
4444
fullSceneLayout.zaxis.r2l(ann.z) * dataScale[2]

Diff for: src/components/legend/defaults.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,13 @@ var helpers = require('./helpers');
1818

1919

2020
module.exports = function legendDefaults(layoutIn, layoutOut, fullData) {
21-
var containerIn = layoutIn.legend || {},
22-
containerOut = layoutOut.legend = {};
21+
var containerIn = layoutIn.legend || {};
22+
var containerOut = {};
2323

24-
var visibleTraces = 0,
25-
defaultOrder = 'normal',
26-
defaultX,
27-
defaultY,
28-
defaultXAnchor,
29-
defaultYAnchor;
24+
var visibleTraces = 0;
25+
var defaultOrder = 'normal';
26+
27+
var defaultX, defaultY, defaultXAnchor, defaultYAnchor;
3028

3129
for(var i = 0; i < fullData.length; i++) {
3230
var trace = fullData[i];
@@ -58,6 +56,8 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) {
5856

5957
if(showLegend === false) return;
6058

59+
layoutOut.legend = containerOut;
60+
6161
coerce('bgcolor', layoutOut.paper_bgcolor);
6262
coerce('bordercolor');
6363
coerce('borderwidth');

0 commit comments

Comments
 (0)