Skip to content

Commit e8bbde1

Browse files
Merge branch 'master' of github.com:plotly/streambed into fix-polar-toolpanel-standalone
Conflicts: shelly/toolpanel/static/toolpanel/package.json
2 parents e1fe4c9 + f2d7066 commit e8bbde1

File tree

14 files changed

+579
-40
lines changed

14 files changed

+579
-40
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"data": [
3+
{
4+
"y": [
5+
-5,
6+
-1,
7+
1
8+
],
9+
"x": [
10+
-1,
11+
0,
12+
1
13+
],
14+
"uid": "e95128"
15+
}
16+
],
17+
"layout": {
18+
"xaxis": {
19+
"linecolor": "rgb(10, 10, 10)",
20+
"gridcolor": "rgb(200, 200, 200)",
21+
"zerolinecolor": "rgb(10, 10, 10)",
22+
"type": "linear",
23+
"range": [
24+
-1.122244488977956,
25+
1.122244488977956
26+
],
27+
"autorange": true
28+
},
29+
"yaxis": {
30+
"linecolor": "rgb(10, 10, 10)",
31+
"gridcolor": "rgb(200, 200, 200)",
32+
"zerolinecolor": "rgb(10, 10, 10)",
33+
"type": "linear",
34+
"range": [
35+
-5.439490445859873,
36+
1.4394904458598727
37+
],
38+
"autorange": true
39+
},
40+
"height": 450,
41+
"width": 1000,
42+
"autosize": true
43+
}
44+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"data": [
3+
{
4+
"y": [
5+
-5,
6+
-1,
7+
1
8+
],
9+
"x": [
10+
-1,
11+
0,
12+
1
13+
],
14+
"uid": "e9539e"
15+
}
16+
],
17+
"layout": {
18+
"xaxis": {
19+
"linewidth": 2,
20+
"gridwidth": 2,
21+
"zerolinewidth": 4,
22+
"type": "linear",
23+
"range": [
24+
-1.122244488977956,
25+
1.122244488977956
26+
],
27+
"autorange": true
28+
},
29+
"yaxis": {
30+
"linewidth": 2,
31+
"gridwidth": 2,
32+
"zerolinewidth": 4,
33+
"type": "linear",
34+
"range": [
35+
-5.439490445859873,
36+
1.4394904458598727
37+
],
38+
"autorange": true
39+
},
40+
"height": 450,
41+
"width": 1000,
42+
"autosize": true
43+
}
44+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"data": [
3+
{
4+
"y": [
5+
-1,
6+
0,
7+
-2
8+
],
9+
"x": [
10+
1,
11+
2,
12+
3
13+
],
14+
"uid": "02de62"
15+
}
16+
],
17+
"layout": {
18+
"xaxis": {
19+
"tickwidth": 2,
20+
"tickcolor": "blue",
21+
"ticklen": 4,
22+
"type": "linear",
23+
"range": [
24+
0.8777555110220441,
25+
3.122244488977956
26+
],
27+
"autorange": true
28+
},
29+
"yaxis": {
30+
"tickwidth": 2,
31+
"tickcolor": "blue",
32+
"ticklen": 4,
33+
"type": "linear",
34+
"range": [
35+
-2.1464968152866244,
36+
0.1464968152866242
37+
],
38+
"autorange": true
39+
},
40+
"height": 450,
41+
"width": 1000,
42+
"autosize": true
43+
}
44+
}
21.3 KB
Loading
22.3 KB
Loading
23.8 KB
Loading

shelly/plotlyjs/static/plotlyjs/src/annotations.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ annotations.draw = function(gd, index, opt, value) {
603603
.style('opacity', options.opacity)
604604
.on('click', function() {
605605
gd._dragging = false;
606-
$(gd).trigger('plotly_clickannotation', {
606+
gd.emit('plotly_clickannotation', {
607607
index: index,
608608
annotation: optionsIn,
609609
fullAnnotation: options

shelly/plotlyjs/static/plotlyjs/src/axes.js

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -630,25 +630,35 @@ axes.handleAxisDefaults = function(containerIn, containerOut, coerce, options) {
630630

631631
axes.handleTickDefaults(containerIn, containerOut, coerce, axType, options);
632632

633-
var showLine = coerce('showline');
634-
if(showLine) {
635-
coerce('linecolor');
636-
coerce('linewidth');
633+
634+
635+
var lineColor = Plotly.Lib.coerce2(containerIn, containerOut, axes.layoutAttributes, 'linecolor'),
636+
lineWidth = Plotly.Lib.coerce2(containerIn, containerOut, axes.layoutAttributes, 'linewidth'),
637+
showLine = coerce('showline', !!lineColor || !!lineWidth);
638+
639+
if(!showLine) {
640+
delete containerOut.linecolor;
641+
delete containerOut.linewidth;
637642
}
638643

639644
if(showLine || containerOut.ticks) coerce('mirror');
640645

641-
642-
var showGridLines = coerce('showgrid', options.showGrid);
643-
if(showGridLines) {
644-
coerce('gridcolor');
645-
coerce('gridwidth');
646+
var gridColor = Plotly.Lib.coerce2(containerIn, containerOut, axes.layoutAttributes, 'gridcolor'),
647+
gridWidth = Plotly.Lib.coerce2(containerIn, containerOut, axes.layoutAttributes, 'gridwidth'),
648+
showGridLines = coerce('showgrid', options.showGrid || !!gridColor || !!gridWidth);
649+
650+
if(!showGridLines) {
651+
delete containerOut.gridcolor;
652+
delete containerOut.gridwidth;
646653
}
647654

648-
var showZeroLine = coerce('zeroline', options.showGrid);
649-
if(showZeroLine) {
650-
coerce('zerolinecolor');
651-
coerce('zerolinewidth');
655+
var zeroLineColor = Plotly.Lib.coerce2(containerIn, containerOut, axes.layoutAttributes, 'zerolinecolor'),
656+
zeroLineWidth = Plotly.Lib.coerce2(containerIn, containerOut, axes.layoutAttributes, 'zerolinewidth'),
657+
showZeroLine = coerce('zeroline', options.showGrid || !!zeroLineColor || !!zeroLineWidth);
658+
659+
if(!showZeroLine) {
660+
delete containerOut.zerolinecolor;
661+
delete containerOut.zerolinewidth;
652662
}
653663

654664
return containerOut;
@@ -658,11 +668,14 @@ axes.handleAxisDefaults = function(containerIn, containerOut, coerce, options) {
658668
* options: inherits font, outerTicks, noHover from axes.handleAxisDefaults
659669
*/
660670
axes.handleTickDefaults = function(containerIn, containerOut, coerce, axType, options) {
661-
var showTicks = coerce('ticks', options.outerTicks ? 'outside' : '');
662-
if(showTicks) {
663-
coerce('ticklen');
664-
coerce('tickwidth');
665-
coerce('tickcolor');
671+
var tickLen = Plotly.Lib.coerce2(containerIn, containerOut, axes.layoutAttributes, 'ticklen'),
672+
tickWidth = Plotly.Lib.coerce2(containerIn, containerOut, axes.layoutAttributes, 'tickwidth'),
673+
tickColor = Plotly.Lib.coerce2(containerIn, containerOut, axes.layoutAttributes, 'tickcolor'),
674+
showTicks = coerce('ticks', (options.outerTicks || tickLen || tickWidth || tickColor) ? 'outside' : '');
675+
if(!showTicks) {
676+
delete containerOut.ticklen;
677+
delete containerOut.tickwidth;
678+
delete containerOut.tickcolor;
666679
}
667680

668681
var showTickLabels = coerce('showticklabels');
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
'use strict';
2+
3+
var EventEmitter = require('events').EventEmitter;
4+
5+
var Events = {
6+
7+
init: function(plotObj) {
8+
9+
/*
10+
* If we have already instantiated an emitter for this plot
11+
* return early.
12+
*/
13+
if (plotObj._ev instanceof EventEmitter) return plotObj;
14+
15+
var ev = new EventEmitter();
16+
17+
/*
18+
* Assign to plot._ev while we still live in a land
19+
* where plot is a DOM element with stuff attached to it.
20+
* In the future we can make plot the event emitter itself.
21+
*/
22+
plotObj._ev = ev;
23+
24+
/*
25+
* Assign bound methods from the ev to the plot object. These methods
26+
* will reference the 'this' of plot._ev even though they are methods
27+
* of plot. This will keep the event machinery away from the plot object
28+
* which currently is often a DOM element but presents an API that will
29+
* continue to function when plot becomes an emitter. Not all EventEmitter
30+
* methods have been bound to `plot` as some do not currently add value to
31+
* the Plotly event API.
32+
*/
33+
plotObj.on = ev.on.bind(ev);
34+
plotObj.once = ev.once.bind(ev);
35+
plotObj.removeListener = ev.removeListener.bind(ev);
36+
plotObj.removeAllListeners = ev.removeAllListeners.bind(ev);
37+
38+
/*
39+
* We must wrap emit to continue to support JQuery events. The idea
40+
* is to check to see if the user is using JQuery events, if they are
41+
* we emit JQuery events to trigger user handlers as well as the EventEmitter
42+
* events.
43+
*/
44+
plotObj.emit = function(event, data) {
45+
if (typeof $ !== 'undefined') {
46+
$(plotObj).trigger(event, data);
47+
}
48+
49+
ev.emit(event, data);
50+
};
51+
52+
return plotObj;
53+
},
54+
55+
/*
56+
* This function behaves like jQueries triggerHandler. It calls
57+
* all handlers for a particular event and returns the return value
58+
* of the LAST handler. This function also triggers jQuery's
59+
* triggerHandler for backwards compatibility.
60+
*/
61+
triggerHandler: function(plotObj, event, data) {
62+
var jQueryHandlerValue;
63+
var nodeEventHandlerValue;
64+
/*
65+
* If Jquery exists run all its handlers for this event and
66+
* collect the return value of the LAST handler function
67+
*/
68+
if (typeof $ !== 'undefined') {
69+
jQueryHandlerValue = $(plotObj).triggerHandler(event, data);
70+
}
71+
72+
/*
73+
* Now run all the node style event handlers
74+
*/
75+
var ev = plotObj._ev;
76+
if (!ev) return jQueryHandlerValue;
77+
78+
var handlers = ev._events[event];
79+
if (!handlers) return jQueryHandlerValue;
80+
81+
/*
82+
* handlers can be function or an array of functions
83+
*/
84+
if (typeof handlers === 'function') handlers = [handlers];
85+
var lastHandler = handlers.pop();
86+
87+
/*
88+
* Call all the handlers except the last one.
89+
*/
90+
for (var i = 0; i < handlers.length; i++) {
91+
handlers[i](data);
92+
}
93+
94+
/*
95+
* Now call the final handler and collect its value
96+
*/
97+
nodeEventHandlerValue = lastHandler(data);
98+
99+
/*
100+
* Return either the jquery handler value if it exists or the
101+
* nodeEventHandler value. Jquery event value superceeds nodejs
102+
* events for backwards compatability reasons.
103+
*/
104+
return jQueryHandlerValue !== undefined ? jQueryHandlerValue :
105+
nodeEventHandlerValue;
106+
}
107+
};
108+
109+
module.exports = Events;

0 commit comments

Comments
 (0)