Skip to content

Commit 9c4c9bf

Browse files
committed
Merge branch 'master' into polar
2 parents cde7369 + 8cc5f55 commit 9c4c9bf

File tree

28 files changed

+729
-396
lines changed

28 files changed

+729
-396
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ and require plotly.js using CommonJS as `var Plotly = require('plotly.js');` or
5454
#### Use the plotly.js CDN hosted by Fastly
5555
```html
5656
<!-- Latest compiled and minified plotly.js JavaScript -->
57-
<script type="text/javascript" src="https://cdn.plot.ly/plotly-latest.min.js"></script>
57+
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
5858

5959
<!-- OR use a specific plotly.js release (e.g. version 1.5.0) -->
60-
<script type="text/javascript" src="https://cdn.plot.ly/plotly-1.5.0.min.js"></script>
60+
<script src="https://cdn.plot.ly/plotly-1.5.0.min.js"></script>
6161

6262
<!-- OR an un-minified version is also available -->
63-
<script type="text/javascript" src="https://cdn.plot.ly/plotly-latest.js"></script>
63+
<script src="https://cdn.plot.ly/plotly-latest.js"></script>
6464
```
6565

6666
and use the `Plotly` object in the window scope.
@@ -99,7 +99,7 @@ To learn more about the plotly.js module architecture, refer to our [modularizin
9999
Important: the plotly.js code base contains some non-ascii characters. Therefore, please make sure to set the `charset` attribute to `"utf-8"` in the script tag that imports your plotly.js bundle. For example:
100100

101101
```html
102-
<script type="text/javascript" src="my-plotly-bundle.js" charset="utf-8"></script>
102+
<script src="my-plotly-bundle.js" charset="utf-8"></script>
103103
```
104104

105105

devtools/image_viewer/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
<div id="plot-images"></div>
88
<pre id="plot-mock"></pre>
99

10-
<script type="text/javascript" src="../../build/image_viewer-bundle.js"></script>
10+
<script src="../../build/image_viewer-bundle.js"></script>
1111
</body>
1212
</html>

devtools/test_dashboard/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
<!-- <script>if(typeof window.Int16Array !== 'function')document.write("<scri"+"pt src='../../dist/extras/typedarray.min.js'></scr"+"ipt>");</script>
2424
<script>document.write("<scri"+"pt src='../../dist/extras/request_animation_frame.js'></scr"+"ipt>");</script> -->
2525

26-
<script type="text/javascript" src="../../dist/extras/mathjax/MathJax.js?config=TeX-AMS-MML_SVG"></script>
27-
<script id="source" type="text/javascript" src="../../build/plotly.js"></script>
28-
<script type="text/javascript" src="../../build/test_dashboard-bundle.js"></script>
26+
<script src="../../dist/extras/mathjax/MathJax.js?config=TeX-AMS-MML_SVG"></script>
27+
<script id="source" src="../../build/plotly.js"></script>
28+
<script src="../../build/test_dashboard-bundle.js"></script>
2929
</body>
3030
</html>

lib/locales/de.js

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,64 @@
1111
module.exports = {
1212
moduleType: 'locale',
1313
name: 'de',
14-
dictionary: {},
14+
dictionary: {
15+
'Autoscale': 'Automatische Skalierung', // components/modebar/buttons.js:139
16+
'Box Select': 'Rechteckauswahl', // components/modebar/buttons.js:103
17+
'Click to enter Colorscale title': 'Klicken, um den Farbskalatitel einzugeben', // plots/plots.js:437
18+
'Click to enter Component A title': 'Klicken, um den Titel der Komponente A einzugeben', // plots/ternary/ternary.js:386
19+
'Click to enter Component B title': 'Klicken, um den Titel der Komponente B einzugeben', // plots/ternary/ternary.js:400
20+
'Click to enter Component C title': 'Klicken, um den Titel der Komponente C einzugeben', // plots/ternary/ternary.js:411
21+
'Click to enter Plot title': 'Klicken, um den Titel des Graphen einzugeben', // plot_api/plot_api.js:579
22+
'Click to enter X axis title': 'Klicken, um den Titel der X-Achse einzugeben', // plots/plots.js:435
23+
'Click to enter Y axis title': 'Klicken, um den Titel der Y-Achse einzugeben', // plots/plots.js:436
24+
'Compare data on hover': 'Über die Daten fahren, um sie zu vergleichen', // components/modebar/buttons.js:167
25+
'Double-click on legend to isolate one trace': 'Daten isolieren durch Doppelklick in der Legende', // components/legend/handle_click.js:90
26+
'Double-click to zoom back out': 'Herauszoomen durch Doppelklick', // plots/cartesian/dragbox.js:299
27+
'Download plot as a png': 'Download als PNG', // components/modebar/buttons.js:52
28+
'Edit in Chart Studio': 'Im Chart Studio bearbeiten', // components/modebar/buttons.js:76
29+
'IE only supports svg. Changing format to svg.': 'IE unterstützt nur SVG-Dateien. Format wird zu SVG gewechselt.', // components/modebar/buttons.js:60
30+
'Lasso Select': 'Lassoauswahl', // components/modebar/buttons.js:112
31+
'Orbital rotation': 'Orbitalrotation', // components/modebar/buttons.js:279
32+
'Pan': 'Verschieben', // components/modebar/buttons.js:94
33+
'Produced with Plotly': 'Erstellt mit Plotly', // components/modebar/modebar.js:256
34+
'Reset': 'Zurücksetzen', // components/modebar/buttons.js:432
35+
'Reset axes': 'Achsen zurücksetzen', // components/modebar/buttons.js:148
36+
'Reset camera to default': 'Kamera auf Standard zurücksetzen', // components/modebar/buttons.js:314
37+
'Reset camera to last save': 'Kamera auf letzte Speicherung zurücksetzen', // components/modebar/buttons.js:322
38+
'Reset view': 'Ansicht zurücksetzen', // components/modebar/buttons.js:583
39+
'Reset views': 'Ansichten zurücksetzen', // components/modebar/buttons.js:529
40+
'Show closest data on hover': 'Zeige näheste Daten beim Überfahren', // components/modebar/buttons.js:157
41+
'Snapshot succeeded': 'Snapshot erfolgreich', // components/modebar/buttons.js:66
42+
'Sorry, there was a problem downloading your snapshot!': 'Es gab ein Problem beim Herunterladen des Snapshots', // components/modebar/buttons.js:69
43+
'Taking snapshot - this may take a few seconds': 'Erstelle einen Snapshot - dies kann einige Sekunden dauern', // components/modebar/buttons.js:57
44+
'Zoom': 'Zoom', // components/modebar/buttons.js:85
45+
'Zoom in': 'Hineinzoomen', // components/modebar/buttons.js:121
46+
'Zoom out': 'Herauszoomen', // components/modebar/buttons.js:130
47+
'close:': 'Schluss:', // traces/ohlc/transform.js:139
48+
'trace': 'Datenspur', // plots/plots.js:439
49+
'lat:': 'Lat.:', // traces/scattergeo/calc.js:48
50+
'lon:': 'Lon.:', // traces/scattergeo/calc.js:49
51+
'q1:': 'q1:', // traces/box/calc.js:130
52+
'q3:': 'q3:', // traces/box/calc.js:131
53+
'source:': 'Quelle:', // traces/sankey/plot.js:140
54+
'target:': 'Ziel:', // traces/sankey/plot.js:141
55+
'lower fence:': 'Untere Schranke:', // traces/box/calc.js:134
56+
'upper fence:': 'Obere Schranke:', // traces/box/calc.js:135
57+
'max:': 'Max.:', // traces/box/calc.js:132
58+
'mean ± σ:': 'Mittelwert ± σ:', // traces/box/calc.js:133
59+
'mean:': 'Mittelwert:', // traces/box/calc.js:133
60+
'median:': 'Median:', // traces/box/calc.js:128
61+
'min:': 'Min.:', // traces/box/calc.js:129
62+
'Turntable rotation': 'Drehscheibenorbit', // components/modebar/buttons.js:288
63+
'Toggle Spike Lines': 'Bezugslinien an-/abschalten', // components/modebar/buttons.js:548
64+
'open:': 'Eröffnung:', // traces/ohlc/transform.js:136
65+
'high:': 'Höchstkurs:', // traces/ohlc/transform.js:137
66+
'low:': 'Tiefstkurs:', // traces/ohlc/transform.js:138
67+
'Toggle show closest data on hover': 'Anzeige der nähesten Daten an-/abschalten', // components/modebar/buttons.js:353
68+
'incoming flow count:': 'Anzahl eingehender Verbindungen:', // traces/sankey/plot.js:142
69+
'outgoing flow count:': 'Anzahl ausgehender Verbindungen:', // traces/sankey/plot.js:143
70+
'kde:': 'Dichte:' // traces/violin/calc.js:73
71+
},
1572
format: {
1673
days: [
1774
'Sonntag', 'Montag', 'Dienstag', 'Mittwoch',

src/components/annotations/draw.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -593,12 +593,10 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
593593
xcenter + ',' + ycenter + ')'
594594
});
595595
},
596-
doneFn: function(dragged) {
597-
if(dragged) {
598-
Plotly.relayout(gd, update);
599-
var notesBox = document.querySelector('.js-notes-box-panel');
600-
if(notesBox) notesBox.redraw(notesBox.selectedObj);
601-
}
596+
doneFn: function() {
597+
Plotly.relayout(gd, update);
598+
var notesBox = document.querySelector('.js-notes-box-panel');
599+
if(notesBox) notesBox.redraw(notesBox.selectedObj);
602600
}
603601
});
604602
}
@@ -673,13 +671,11 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
673671

674672
setCursor(annTextGroupInner, csr);
675673
},
676-
doneFn: function(dragged) {
674+
doneFn: function() {
677675
setCursor(annTextGroupInner);
678-
if(dragged) {
679-
Plotly.relayout(gd, update);
680-
var notesBox = document.querySelector('.js-notes-box-panel');
681-
if(notesBox) notesBox.redraw(notesBox.selectedObj);
682-
}
676+
Plotly.relayout(gd, update);
677+
var notesBox = document.querySelector('.js-notes-box-panel');
678+
if(notesBox) notesBox.redraw(notesBox.selectedObj);
683679
}
684680
});
685681
}

src/components/colorbar/draw.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,10 +584,10 @@ module.exports = function draw(gd, id) {
584584
opts.xanchor, opts.yanchor);
585585
setCursor(container, csr);
586586
},
587-
doneFn: function(dragged) {
587+
doneFn: function() {
588588
setCursor(container);
589589

590-
if(dragged && xf !== undefined && yf !== undefined) {
590+
if(xf !== undefined && yf !== undefined) {
591591
Plotly.restyle(gd,
592592
{'colorbar.x': xf, 'colorbar.y': yf},
593593
getTrace().index);

src/components/dragelement/index.js

Lines changed: 64 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,44 @@ dragElement.unhoverRaw = unhover.raw;
3838
* - Freezes the cursor: whatever mouse cursor the drag element had when the
3939
* interaction started gets copied to the coverSlip for use until mouseup
4040
*
41+
* If the user executes a drag bigger than MINDRAG, callbacks will fire as:
42+
* prepFn, moveFn (1 or more times), doneFn
43+
* If the user does not drag enough, prepFn and clickFn will fire.
44+
*
45+
* Note: If you cancel contextmenu, clickFn will fire even with a right click
46+
* (unlike native events) so you'll get a `plotly_click` event. Cancel context eg:
47+
* gd.addEventListener('contextmenu', function(e) { e.preventDefault(); });
48+
* TODO: we should probably turn this into a `config` parameter, so we can fix it
49+
* such that if you *don't* cancel contextmenu, we can prevent partial drags, which
50+
* put you in a weird state.
51+
*
52+
* If the user clicks multiple times quickly, clickFn will fire each time
53+
* but numClicks will increase to help you recognize doubleclicks.
54+
*
4155
* @param {object} options with keys:
4256
* element (required) the DOM element to drag
4357
* prepFn (optional) function(event, startX, startY)
4458
* executed on mousedown
4559
* startX and startY are the clientX and clientY pixel position
4660
* of the mousedown event
47-
* moveFn (optional) function(dx, dy, dragged)
48-
* executed on move
61+
* moveFn (optional) function(dx, dy)
62+
* executed on move, ONLY after we've exceeded MINDRAG
63+
* (we keep executing moveFn if you move back to where you started)
4964
* dx and dy are the net pixel offset of the drag,
5065
* dragged is true/false, has the mouse moved enough to
5166
* constitute a drag
52-
* doneFn (optional) function(dragged, numClicks, e)
53-
* executed on mouseup, or mouseout of window since
54-
* we don't get events after that
55-
* dragged is as in moveFn
67+
* doneFn (optional) function(e)
68+
* executed on mouseup, ONLY if we exceeded MINDRAG (so you can be
69+
* sure that moveFn has been called at least once)
70+
* numClicks is how many clicks we've registered within
71+
* a doubleclick time
72+
* e is the original mouseup event
73+
* clickFn (optional) function(numClicks, e)
74+
* executed on mouseup if we have NOT exceeded MINDRAG (ie moveFn
75+
* has not been called at all)
5676
* numClicks is how many clicks we've registered within
5777
* a doubleclick time
58-
* e is the original event
78+
* e is the original mousedown event
5979
*/
6080
dragElement.init = function init(options) {
6181
var gd = options.gd;
@@ -68,7 +88,9 @@ dragElement.init = function init(options) {
6888
newMouseDownTime,
6989
cursor,
7090
dragCover,
71-
initialTarget;
91+
initialEvent,
92+
initialTarget,
93+
rightClick;
7294

7395
if(!gd._mouseDownTime) gd._mouseDownTime = 0;
7496

@@ -78,10 +100,6 @@ dragElement.init = function init(options) {
78100
element.ontouchstart = onStart;
79101

80102
function onStart(e) {
81-
if(e.buttons && e.buttons === 2) { // right click
82-
return;
83-
}
84-
85103
// make dragging and dragged into properties of gd
86104
// so that others can look at and modify them
87105
gd._dragged = false;
@@ -90,6 +108,8 @@ dragElement.init = function init(options) {
90108
startX = offset[0];
91109
startY = offset[1];
92110
initialTarget = e.target;
111+
initialEvent = e;
112+
rightClick = (e.buttons && e.buttons === 2) || e.ctrlKey;
93113

94114
newMouseDownTime = (new Date()).getTime();
95115
if(newMouseDownTime - gd._mouseDownTime < DBLCLICKDELAY) {
@@ -104,11 +124,11 @@ dragElement.init = function init(options) {
104124

105125
if(options.prepFn) options.prepFn(e, startX, startY);
106126

107-
if(hasHover) {
127+
if(hasHover && !rightClick) {
108128
dragCover = coverSlip();
109129
dragCover.style.cursor = window.getComputedStyle(element).cursor;
110130
}
111-
else {
131+
else if(!hasHover) {
112132
// document acts as a dragcover for mobile, bc we can't create dragcover dynamically
113133
dragCover = document;
114134
cursor = window.getComputedStyle(document.documentElement).cursor;
@@ -136,7 +156,7 @@ dragElement.init = function init(options) {
136156
dragElement.unhover(gd);
137157
}
138158

139-
if(options.moveFn) options.moveFn(dx, dy, gd._dragged);
159+
if(gd._dragged && options.moveFn && !rightClick) options.moveFn(dx, dy);
140160

141161
return Lib.pauseEvent(e);
142162
}
@@ -167,27 +187,36 @@ dragElement.init = function init(options) {
167187
numClicks = Math.max(numClicks - 1, 1);
168188
}
169189

170-
if(options.doneFn) options.doneFn(gd._dragged, numClicks, e);
171-
172-
if(!gd._dragged) {
173-
var e2;
174-
175-
try {
176-
e2 = new MouseEvent('click', e);
177-
}
178-
catch(err) {
179-
var offset = pointerOffset(e);
180-
e2 = document.createEvent('MouseEvents');
181-
e2.initMouseEvent('click',
182-
e.bubbles, e.cancelable,
183-
e.view, e.detail,
184-
e.screenX, e.screenY,
185-
offset[0], offset[1],
186-
e.ctrlKey, e.altKey, e.shiftKey, e.metaKey,
187-
e.button, e.relatedTarget);
190+
if(gd._dragged) {
191+
if(options.doneFn) options.doneFn(e);
192+
}
193+
else {
194+
if(options.clickFn) options.clickFn(numClicks, initialEvent);
195+
196+
// If we haven't dragged, this should be a click. But because of the
197+
// coverSlip changing the element, the natural system might not generate one,
198+
// so we need to make our own. But right clicks don't normally generate
199+
// click events, only contextmenu events, which happen on mousedown.
200+
if(!rightClick) {
201+
var e2;
202+
203+
try {
204+
e2 = new MouseEvent('click', e);
205+
}
206+
catch(err) {
207+
var offset = pointerOffset(e);
208+
e2 = document.createEvent('MouseEvents');
209+
e2.initMouseEvent('click',
210+
e.bubbles, e.cancelable,
211+
e.view, e.detail,
212+
e.screenX, e.screenY,
213+
offset[0], offset[1],
214+
e.ctrlKey, e.altKey, e.shiftKey, e.metaKey,
215+
e.button, e.relatedTarget);
216+
}
217+
218+
initialTarget.dispatchEvent(e2);
188219
}
189-
190-
initialTarget.dispatchEvent(e2);
191220
}
192221

193222
finishDrag(gd);

0 commit comments

Comments
 (0)