Skip to content

Commit 261cb9d

Browse files
committed
Merge branch 'master' of https://github.com/plotly/plotly.js into darabos-multiline-labels
2 parents 4431506 + 8731cb5 commit 261cb9d

File tree

169 files changed

+2741
-1610
lines changed

Some content is hidden

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

169 files changed

+2741
-1610
lines changed

.eslintrc

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"Int16Array": true,
1818
"Int32Array": true,
1919
"ArrayBuffer": true,
20+
"DataView": true,
2021
"SVGElement": false
2122
},
2223
"rules": {

src/components/annotations/click.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9-
109
'use strict';
1110

12-
var Plotly = require('../../plotly');
13-
11+
var Registry = require('../../registry');
1412

1513
module.exports = {
1614
hasClickToShow: hasClickToShow,
@@ -59,7 +57,7 @@ function onClick(gd, hoverData) {
5957
update['annotations[' + offSet[i] + '].visible'] = false;
6058
}
6159

62-
return Plotly.update(gd, {}, update);
60+
return Registry.call('update', gd, {}, update);
6361
}
6462

6563
/*

src/components/annotations/draw.js

+4-7
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9-
109
'use strict';
1110

1211
var d3 = require('d3');
1312

14-
var Plotly = require('../../plotly');
13+
var Registry = require('../../registry');
1514
var Plots = require('../../plots/plots');
1615
var Lib = require('../../lib');
1716
var Axes = require('../../plots/cartesian/axes');
@@ -21,10 +20,8 @@ var Fx = require('../fx');
2120
var svgTextUtils = require('../../lib/svg_text_utils');
2221
var setCursor = require('../../lib/setcursor');
2322
var dragElement = require('../dragelement');
24-
2523
var drawArrowHead = require('./draw_arrow_head');
2624

27-
2825
// Annotations are stored in gd.layout.annotations, an array of objects
2926
// index can point to one item in this array,
3027
// or non-numeric to simply add a new one
@@ -594,7 +591,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
594591
});
595592
},
596593
doneFn: function() {
597-
Plotly.relayout(gd, update);
594+
Registry.call('relayout', gd, update);
598595
var notesBox = document.querySelector('.js-notes-box-panel');
599596
if(notesBox) notesBox.redraw(notesBox.selectedObj);
600597
}
@@ -676,7 +673,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
676673
},
677674
doneFn: function() {
678675
setCursor(annTextGroupInner);
679-
Plotly.relayout(gd, update);
676+
Registry.call('relayout', gd, update);
680677
var notesBox = document.querySelector('.js-notes-box-panel');
681678
if(notesBox) notesBox.redraw(notesBox.selectedObj);
682679
}
@@ -701,7 +698,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
701698
update[ya._name + '.autorange'] = true;
702699
}
703700

704-
Plotly.relayout(gd, update);
701+
Registry.call('relayout', gd, update);
705702
});
706703
}
707704
else annText.call(textLayout);

src/components/colorbar/draw.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
var d3 = require('d3');
1313
var tinycolor = require('tinycolor2');
1414

15-
var Plotly = require('../../plotly');
1615
var Plots = require('../../plots/plots');
1716
var Registry = require('../../registry');
1817
var Axes = require('../../plots/cartesian/axes');
@@ -588,9 +587,11 @@ module.exports = function draw(gd, id) {
588587
setCursor(container);
589588

590589
if(xf !== undefined && yf !== undefined) {
591-
Plotly.restyle(gd,
590+
Registry.call('restyle',
591+
gd,
592592
{'colorbar.x': xf, 'colorbar.y': yf},
593-
getTrace().index);
593+
getTrace().index
594+
);
594595
}
595596
}
596597
});

src/components/colorscale/has_colorscale.js

+5-9
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,20 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9-
109
'use strict';
1110

1211
var isNumeric = require('fast-isnumeric');
13-
1412
var Lib = require('../../lib');
15-
1613
var isValidScale = require('./is_valid_scale');
1714

18-
1915
module.exports = function hasColorscale(trace, containerStr) {
2016
var container = containerStr ?
21-
Lib.nestedProperty(trace, containerStr).get() || {} :
22-
trace,
23-
color = container.color,
24-
isArrayWithOneNumber = false;
17+
Lib.nestedProperty(trace, containerStr).get() || {} :
18+
trace;
19+
var color = container.color;
2520

26-
if(Array.isArray(color)) {
21+
var isArrayWithOneNumber = false;
22+
if(Lib.isArrayOrTypedArray(color)) {
2723
for(var i = 0; i < color.length; i++) {
2824
if(isNumeric(color[i])) {
2925
isArrayWithOneNumber = true;

src/components/dragelement/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var mouseOffset = require('mouse-event-offset');
1313
var hasHover = require('has-hover');
1414
var supportsPassive = require('has-passive-events');
1515

16-
var Plotly = require('../../plotly');
16+
var Registry = require('../../registry');
1717
var Lib = require('../../lib');
1818

1919
var constants = require('../../plots/cartesian/constants');
@@ -135,7 +135,7 @@ dragElement.init = function init(options) {
135135
startY = offset[1];
136136
initialTarget = e.target;
137137
initialEvent = e;
138-
rightClick = (e.buttons && e.buttons === 2) || e.ctrlKey;
138+
rightClick = e.buttons === 2 || e.ctrlKey;
139139

140140
newMouseDownTime = (new Date()).getTime();
141141
if(newMouseDownTime - gd._mouseDownTime < DBLCLICKDELAY) {
@@ -278,7 +278,7 @@ dragElement.coverSlip = coverSlip;
278278

279279
function finishDrag(gd) {
280280
gd._dragging = false;
281-
if(gd._replotPending) Plotly.plot(gd);
281+
if(gd._replotPending) Registry.call('plot', gd);
282282
}
283283

284284
function pointerOffset(e) {

src/components/drawing/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -316,10 +316,10 @@ function singlePointStyle(d, sel, trace, markerScale, lineScale, marker, markerL
316316

317317
if('mlc' in d) lineColor = d.mlcc = lineScale(d.mlc);
318318
// weird case: array wasn't long enough to apply to every point
319-
else if(Array.isArray(markerLine.color)) lineColor = Color.defaultLine;
319+
else if(Lib.isArrayOrTypedArray(markerLine.color)) lineColor = Color.defaultLine;
320320
else lineColor = markerLine.color;
321321

322-
if(Array.isArray(marker.color)) {
322+
if(Lib.isArrayOrTypedArray(marker.color)) {
323323
fillColor = Color.defaultLine;
324324
perPointGradient = true;
325325
}
@@ -542,7 +542,7 @@ drawing.tryColorscale = function(marker, prefix) {
542542
scl = cont.colorscale,
543543
colorArray = cont.color;
544544

545-
if(scl && Array.isArray(colorArray)) {
545+
if(scl && Lib.isArrayOrTypedArray(colorArray)) {
546546
return Colorscale.makeColorScaleFunc(
547547
Colorscale.extractScale(scl, cont.cmin, cont.cmax)
548548
);

src/components/errorbars/index.js

+49-14
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,57 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9-
109
'use strict';
1110

12-
var errorBars = module.exports = {};
11+
var Lib = require('../../lib');
12+
var overrideAll = require('../../plot_api/edit_types').overrideAll;
13+
14+
var attributes = require('./attributes');
15+
var calc = require('./calc');
16+
17+
var xyAttrs = {
18+
error_x: Lib.extendFlat({}, attributes),
19+
error_y: Lib.extendFlat({}, attributes)
20+
};
21+
delete xyAttrs.error_x.copy_zstyle;
22+
delete xyAttrs.error_y.copy_zstyle;
23+
delete xyAttrs.error_y.copy_ystyle;
24+
25+
var xyzAttrs = {
26+
error_x: Lib.extendFlat({}, attributes),
27+
error_y: Lib.extendFlat({}, attributes),
28+
error_z: Lib.extendFlat({}, attributes)
29+
};
30+
delete xyzAttrs.error_x.copy_ystyle;
31+
delete xyzAttrs.error_y.copy_ystyle;
32+
delete xyzAttrs.error_z.copy_ystyle;
33+
delete xyzAttrs.error_z.copy_zstyle;
34+
35+
module.exports = {
36+
moduleType: 'component',
37+
name: 'errorbars',
1338

14-
errorBars.attributes = require('./attributes');
39+
schema: {
40+
traces: {
41+
scatter: xyAttrs,
42+
bar: xyAttrs,
43+
histogram: xyAttrs,
44+
scatter3d: overrideAll(xyzAttrs, 'calc', 'nested'),
45+
scattergl: overrideAll(xyAttrs, 'calc', 'nested')
46+
}
47+
},
1548

16-
errorBars.supplyDefaults = require('./defaults');
49+
supplyDefaults: require('./defaults'),
1750

18-
errorBars.calc = require('./calc');
51+
calc: calc,
52+
calcFromTrace: calcFromTrace,
1953

20-
errorBars.calcFromTrace = function(trace, layout) {
54+
plot: require('./plot'),
55+
style: require('./style'),
56+
hoverInfo: hoverInfo
57+
};
58+
59+
function calcFromTrace(trace, layout) {
2160
var x = trace.x || [],
2261
y = trace.y || [],
2362
len = x.length || y.length;
@@ -33,19 +72,15 @@ errorBars.calcFromTrace = function(trace, layout) {
3372

3473
calcdataMock[0].trace = trace;
3574

36-
errorBars.calc({
75+
calc({
3776
calcdata: [calcdataMock],
3877
_fullLayout: layout
3978
});
4079

4180
return calcdataMock;
42-
};
81+
}
4382

44-
errorBars.plot = require('./plot');
45-
46-
errorBars.style = require('./style');
47-
48-
errorBars.hoverInfo = function(calcPoint, trace, hoverPoint) {
83+
function hoverInfo(calcPoint, trace, hoverPoint) {
4984
if((trace.error_y || {}).visible) {
5085
hoverPoint.yerr = calcPoint.yh - calcPoint.y;
5186
if(!trace.error_y.symmetric) hoverPoint.yerrneg = calcPoint.y - calcPoint.ys;
@@ -54,4 +89,4 @@ errorBars.hoverInfo = function(calcPoint, trace, hoverPoint) {
5489
hoverPoint.xerr = calcPoint.xh - calcPoint.x;
5590
if(!trace.error_x.symmetric) hoverPoint.xerrneg = calcPoint.x - calcPoint.xs;
5691
}
57-
};
92+
}

src/components/fx/hover.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1126,7 +1126,7 @@ function alignHoverText(hoverLabels, rotateLabels) {
11261126
offsetY = d.offset;
11271127
if(d.anchor === 'middle') {
11281128
txx -= d.tx2width / 2;
1129-
tx2x -= d.tx2width / 2;
1129+
tx2x += d.txwidth / 2 + HOVERTEXTPAD;
11301130
}
11311131
if(rotateLabels) {
11321132
offsetY *= -YSHIFTY;
@@ -1135,7 +1135,8 @@ function alignHoverText(hoverLabels, rotateLabels) {
11351135

11361136
g.select('path').attr('d', d.anchor === 'middle' ?
11371137
// middle aligned: rect centered on data
1138-
('M-' + (d.bx / 2) + ',-' + (d.by / 2) + 'h' + d.bx + 'v' + d.by + 'h-' + d.bx + 'Z') :
1138+
('M-' + (d.bx / 2 + d.tx2width / 2) + ',-' + (d.by / 2) +
1139+
'h' + d.bx + 'v' + d.by + 'h-' + d.bx + 'Z') :
11391140
// left or right aligned: side rect with arrow to data
11401141
('M0,0L' + (horzSign * HOVERARROWSIZE + offsetX) + ',' + (HOVERARROWSIZE + offsetY) +
11411142
'v' + (d.by / 2 - HOVERARROWSIZE) +

src/plots/grid.js renamed to src/components/grid/index.js

+22-10
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@
88

99
'use strict';
1010

11-
var Lib = require('../lib');
12-
var domainAttrs = require('./domain').attributes;
13-
var counterRegex = require('../lib/regex').counter;
14-
var cartesianIdRegex = require('./cartesian/constants').idRegex;
11+
var Lib = require('../../lib');
12+
var counterRegex = require('../../lib/regex').counter;
13+
var domainAttrs = require('../../plots/domain').attributes;
14+
var cartesianIdRegex = require('../../plots/cartesian/constants').idRegex;
1515

16-
17-
var gridAttrs = exports.attributes = {
16+
var gridAttrs = {
1817
rows: {
1918
valType: 'integer',
2019
min: 1,
@@ -168,7 +167,7 @@ var gridAttrs = exports.attributes = {
168167

169168
// the shape of the grid - this needs to be done BEFORE supplyDataDefaults
170169
// so that non-subplot traces can place themselves in the grid
171-
exports.sizeDefaults = function(layoutIn, layoutOut) {
170+
function sizeDefaults(layoutIn, layoutOut) {
172171
var gridIn = layoutIn.grid;
173172
if(!gridIn) return;
174173

@@ -211,7 +210,7 @@ exports.sizeDefaults = function(layoutIn, layoutOut) {
211210
x: fillGridPositions('x', coerce, hasSubplotGrid ? 0.2 : 0.1, columns),
212211
y: fillGridPositions('y', coerce, hasSubplotGrid ? 0.3 : 0.1, rows, reversed)
213212
};
214-
};
213+
}
215214

216215
// coerce x or y sizing attributes and return an array of domains for this direction
217216
function fillGridPositions(axLetter, coerce, dfltGap, len, reversed) {
@@ -232,7 +231,7 @@ function fillGridPositions(axLetter, coerce, dfltGap, len, reversed) {
232231

233232
// the (cartesian) contents of the grid - this needs to happen AFTER supplyDataDefaults
234233
// so that we know what cartesian subplots are available
235-
exports.contentDefaults = function(layoutIn, layoutOut) {
234+
function contentDefaults(layoutIn, layoutOut) {
236235
var gridOut = layoutOut.grid;
237236
// make sure we got to the end of handleGridSizing
238237
if(!gridOut || !gridOut._domains) return;
@@ -368,7 +367,7 @@ exports.contentDefaults = function(layoutIn, layoutOut) {
368367
}
369368
}
370369
}
371-
};
370+
}
372371

373372
function fillGridAxes(axesIn, axesAllowed, len, axisMap, axLetter) {
374373
var out = new Array(len);
@@ -397,3 +396,16 @@ function fillGridAxes(axesIn, axesAllowed, len, axisMap, axLetter) {
397396

398397
return out;
399398
}
399+
400+
module.exports = {
401+
moduleType: 'component',
402+
name: 'grid',
403+
404+
schema: {
405+
layout: {grid: gridAttrs}
406+
},
407+
408+
layoutAttributes: gridAttrs,
409+
sizeDefaults: sizeDefaults,
410+
contentDefaults: contentDefaults
411+
};

src/components/legend/constants.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
'use strict';
1010

1111
module.exports = {
12-
scrollBarWidth: 4,
13-
scrollBarHeight: 20,
12+
scrollBarWidth: 6,
13+
scrollBarMinHeight: 20,
1414
scrollBarColor: '#808BA4',
1515
scrollBarMargin: 4
1616
};

0 commit comments

Comments
 (0)