Skip to content

Commit 76a103f

Browse files
committed
Merge branch 'master' into mesh3d-colorscale-settings
2 parents 4cd0876 + e37eeae commit 76a103f

Some content is hidden

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

49 files changed

+1726
-335
lines changed

.eslintrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"Uint8Array": true,
1717
"Int16Array": true,
1818
"Int32Array": true,
19-
"ArrayBuffer": true
19+
"ArrayBuffer": true,
20+
"SVGElement": false
2021
},
2122
"rules": {
2223
"no-trailing-spaces": [2],

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,10 @@ plotly.js charts can also be created and saved online for free at [plot.ly/plot]
160160
|---|--------|---------|
161161
|**Alex C. Johnson**| [@alexcjohnson](https://github.com/alexcjohnson) | |
162162
|**Étienne Tétreault-Pinard**| [@etpinard](https://github.com/etpinard) | [@etpinard](https://twitter.com/etpinard) |
163-
|**Mikola Lysenko**| [@mikolalysenko](https://github.com/mikolalysenko) | [@MikolaLysenko](https://twitter.com/MikolaLysenko) | |
163+
|**Mikola Lysenko**| [@mikolalysenko](https://github.com/mikolalysenko) | [@MikolaLysenko](https://twitter.com/MikolaLysenko) |
164+
|**Ricky Reusser**| [@rreusser](https://github.com/rreusser) | [@rickyreusser](https://twitter.com/rickyreusser) |
165+
|**Robert Monfera**| [@monfera](https://github.com/monfera) | [@monfera](https://twitter.com/monfera) |
166+
|**Nicolas Riesco**| [@n-riesco](https://github.com/n-riesco) | |
164167
|**Miklós Tusz**| [@mdtusz](https://github.com/mdtusz) | [@mdtusz](https://twitter.com/mdtusz)|
165168
|**Chelsea Douglas**| [@cldougl](https://github.com/cldougl) | |
166169
|**Ben Postlethwaite**| [@bpostlethwaite](https://github.com/bpostlethwaite) | |

src/components/annotations/annotation_defaults.js

+10-50
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@
1010
'use strict';
1111

1212
var Lib = require('../../lib');
13-
var Color = require('../color');
1413
var Axes = require('../../plots/cartesian/axes');
15-
14+
var handleAnnotationCommonDefaults = require('./common_defaults');
1615
var attributes = require('./attributes');
1716

1817

@@ -29,26 +28,9 @@ module.exports = function handleAnnotationDefaults(annIn, annOut, fullLayout, op
2928

3029
if(!(visible || clickToShow)) return annOut;
3130

32-
coerce('opacity');
33-
var bgColor = coerce('bgcolor');
34-
35-
var borderColor = coerce('bordercolor'),
36-
borderOpacity = Color.opacity(borderColor);
37-
38-
coerce('borderpad');
39-
40-
var borderWidth = coerce('borderwidth');
41-
var showArrow = coerce('showarrow');
42-
43-
coerce('text', showArrow ? ' ' : 'new text');
44-
coerce('textangle');
45-
Lib.coerceFont(coerce, 'font', fullLayout.font);
46-
47-
coerce('width');
48-
coerce('align');
31+
handleAnnotationCommonDefaults(annIn, annOut, fullLayout, coerce);
4932

50-
var h = coerce('height');
51-
if(h) coerce('valign');
33+
var showArrow = annOut.showarrow;
5234

5335
// positioning
5436
var axLetters = ['x', 'y'],
@@ -90,14 +72,8 @@ module.exports = function handleAnnotationDefaults(annIn, annOut, fullLayout, op
9072
// if you have one coordinate you should have both
9173
Lib.noneOrAll(annIn, annOut, ['x', 'y']);
9274

75+
// if you have one part of arrow length you should have both
9376
if(showArrow) {
94-
coerce('arrowcolor', borderOpacity ? annOut.bordercolor : Color.defaultLine);
95-
coerce('arrowhead');
96-
coerce('arrowsize');
97-
coerce('arrowwidth', ((borderOpacity && borderWidth) || 1) * 2);
98-
coerce('standoff');
99-
100-
// if you have one part of arrow length you should have both
10177
Lib.noneOrAll(annIn, annOut, ['ax', 'ay']);
10278
}
10379

@@ -107,29 +83,13 @@ module.exports = function handleAnnotationDefaults(annIn, annOut, fullLayout, op
10783

10884
// put the actual click data to bind to into private attributes
10985
// so we don't have to do this little bit of logic on every hover event
110-
annOut._xclick = (xClick === undefined) ? annOut.x : xClick;
111-
annOut._yclick = (yClick === undefined) ? annOut.y : yClick;
112-
}
113-
114-
var hoverText = coerce('hovertext');
115-
var globalHoverLabel = fullLayout.hoverlabel || {};
116-
117-
if(hoverText) {
118-
var hoverBG = coerce('hoverlabel.bgcolor', globalHoverLabel.bgcolor ||
119-
(Color.opacity(bgColor) ? Color.rgb(bgColor) : Color.defaultLine)
120-
);
121-
122-
var hoverBorder = coerce('hoverlabel.bordercolor', globalHoverLabel.bordercolor ||
123-
Color.contrast(hoverBG)
124-
);
125-
126-
Lib.coerceFont(coerce, 'hoverlabel.font', {
127-
family: globalHoverLabel.font.family,
128-
size: globalHoverLabel.font.size,
129-
color: globalHoverLabel.font.color || hoverBorder
130-
});
86+
annOut._xclick = (xClick === undefined) ?
87+
annOut.x :
88+
Axes.cleanPosition(xClick, gdMock, annOut.xref);
89+
annOut._yclick = (yClick === undefined) ?
90+
annOut.y :
91+
Axes.cleanPosition(yClick, gdMock, annOut.yref);
13192
}
132-
coerce('captureevents', !!hoverText);
13393

13494
return annOut;
13595
};

src/components/annotations/click.js

+14-5
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,22 @@ function getToggleSets(gd, hoverData) {
8383
explicitOffSet = [],
8484
hoverLen = (hoverData || []).length;
8585

86-
var i, j, anni, showMode, pointj, toggleType;
86+
var i, j, anni, showMode, pointj, xa, ya, toggleType;
8787

8888
for(i = 0; i < annotations.length; i++) {
8989
anni = annotations[i];
9090
showMode = anni.clicktoshow;
91+
9192
if(showMode) {
9293
for(j = 0; j < hoverLen; j++) {
9394
pointj = hoverData[j];
94-
if(pointj.xaxis._id === anni.xref &&
95-
pointj.yaxis._id === anni.yref &&
96-
pointj.xaxis.d2r(pointj.x) === anni._xclick &&
97-
pointj.yaxis.d2r(pointj.y) === anni._yclick
95+
xa = pointj.xaxis;
96+
ya = pointj.yaxis;
97+
98+
if(xa._id === anni.xref &&
99+
ya._id === anni.yref &&
100+
xa.d2r(pointj.x) === clickData2r(anni._xclick, xa) &&
101+
ya.d2r(pointj.y) === clickData2r(anni._yclick, ya)
98102
) {
99103
// match! toggle this annotation
100104
// regardless of its clicktoshow mode
@@ -121,3 +125,8 @@ function getToggleSets(gd, hoverData) {
121125

122126
return {on: onSet, off: offSet, explicitOff: explicitOffSet};
123127
}
128+
129+
// to handle log axes until v2
130+
function clickData2r(d, ax) {
131+
return ax.type === 'log' ? ax.l2r(d) : ax.d2r(d);
132+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/**
2+
* Copyright 2012-2017, Plotly, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
'use strict';
10+
11+
var Lib = require('../../lib');
12+
var Color = require('../color');
13+
14+
// defaults common to 'annotations' and 'annotations3d'
15+
module.exports = function handleAnnotationCommonDefaults(annIn, annOut, fullLayout, coerce) {
16+
coerce('opacity');
17+
var bgColor = coerce('bgcolor');
18+
19+
var borderColor = coerce('bordercolor');
20+
var borderOpacity = Color.opacity(borderColor);
21+
22+
coerce('borderpad');
23+
24+
var borderWidth = coerce('borderwidth');
25+
var showArrow = coerce('showarrow');
26+
27+
coerce('text', showArrow ? ' ' : 'new text');
28+
coerce('textangle');
29+
Lib.coerceFont(coerce, 'font', fullLayout.font);
30+
31+
coerce('width');
32+
coerce('align');
33+
34+
var h = coerce('height');
35+
if(h) coerce('valign');
36+
37+
if(showArrow) {
38+
coerce('arrowcolor', borderOpacity ? annOut.bordercolor : Color.defaultLine);
39+
coerce('arrowhead');
40+
coerce('arrowsize');
41+
coerce('arrowwidth', ((borderOpacity && borderWidth) || 1) * 2);
42+
coerce('standoff');
43+
44+
}
45+
46+
var hoverText = coerce('hovertext');
47+
var globalHoverLabel = fullLayout.hoverlabel || {};
48+
49+
if(hoverText) {
50+
var hoverBG = coerce('hoverlabel.bgcolor', globalHoverLabel.bgcolor ||
51+
(Color.opacity(bgColor) ? Color.rgb(bgColor) : Color.defaultLine)
52+
);
53+
54+
var hoverBorder = coerce('hoverlabel.bordercolor', globalHoverLabel.bordercolor ||
55+
Color.contrast(hoverBG)
56+
);
57+
58+
Lib.coerceFont(coerce, 'hoverlabel.font', {
59+
family: globalHoverLabel.font.family,
60+
size: globalHoverLabel.font.size,
61+
color: globalHoverLabel.font.color || hoverBorder
62+
});
63+
}
64+
65+
coerce('captureevents', !!hoverText);
66+
};

0 commit comments

Comments
 (0)