Skip to content

Commit fa807e8

Browse files
authored
Merge branch 'master' into rotate3d-axis-lables
2 parents 4500ea3 + d340150 commit fa807e8

29 files changed

+866
-88
lines changed

build/plotcss.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ var rules = {
3737
"X .modebar-group": "float:left;display:inline-block;box-sizing:border-box;margin-left:8px;position:relative;vertical-align:middle;white-space:nowrap;",
3838
"X .modebar-btn": "position:relative;font-size:16px;padding:3px 4px;height:22px;cursor:pointer;line-height:normal;box-sizing:border-box;",
3939
"X .modebar-btn svg": "position:relative;top:2px;",
40-
"X .modebar.vertical": "top:-1px;",
40+
"X .modebar.vertical": "top:-1px;display:flex;flex-direction:column;flex-wrap:wrap;height:100%;align-content:flex-end;",
4141
"X .modebar.vertical .modebar-group": "display:block;float:none;margin-left:0px;margin-bottom:8px;",
4242
"X .modebar.vertical .modebar-group .modebar-btn": "display:block;text-align:center;",
4343
"X [data-title]:before,X [data-title]:after": "position:absolute;-webkit-transform:translate3d(0, 0, 0);-moz-transform:translate3d(0, 0, 0);-ms-transform:translate3d(0, 0, 0);-o-transform:translate3d(0, 0, 0);transform:translate3d(0, 0, 0);display:none;opacity:0;z-index:1001;pointer-events:none;top:110%;right:50%;",

src/css/_modebar.scss

+5
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@
4646

4747
.modebar.vertical {
4848
top: -1px;
49+
display: flex;
50+
flex-direction: column;
51+
flex-wrap: wrap;
52+
height: 100%;
53+
align-content: flex-end;
4954
.modebar-group {
5055
display: block;
5156
float: none;

src/plot_api/plot_api.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,10 @@ function setPlotContext(gd, config) {
488488
if(context.setBackground === 'transparent' || typeof context.setBackground !== 'function') {
489489
context.setBackground = setBackground;
490490
}
491+
492+
// Check if gd has a specified widht/height to begin with
493+
context._hasZeroHeight = context._hasZeroHeight || gd.clientHeight === 0;
494+
context._hasZeroWidth = context._hasZeroWidth || gd.clientWidth === 0;
491495
}
492496

493497
function plotPolar(gd, data, layout) {
@@ -3248,9 +3252,6 @@ function makePlotFramework(gd) {
32483252
var gd3 = d3.select(gd);
32493253
var fullLayout = gd._fullLayout;
32503254

3251-
// Check if gd has a specified height
3252-
fullLayout._hasZeroHeight = gd.clientHeight === 0;
3253-
32543255
// Plot container
32553256
fullLayout._container = gd3.selectAll('.plot-container').data([0]);
32563257
fullLayout._container.enter().insert('div', ':first-child')

src/plot_api/plot_config.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ module.exports = {
5757
*/
5858
autosizable: false,
5959

60-
// responsive: determines whether to change the layout size when window is resized
60+
/*
61+
* responsive: determines whether to change the layout size when window is resized.
62+
* In v2, this option will be removed and will always be true.
63+
*/
6164
responsive: false,
6265

6366
// set the length of the undo/redo queue

src/plot_api/subroutines.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ function lsInner(gd) {
5454
var i, subplot, plotinfo, xa, ya;
5555

5656
fullLayout._paperdiv.style({
57-
width: (fullLayout.autosize) ? '100%' : fullLayout.width + 'px',
58-
height: (fullLayout.autosize && !fullLayout._hasZeroHeight) ? '100%' : fullLayout.height + 'px'
57+
width: (gd._context.responsive && fullLayout.autosize && !gd._context._hasZeroWidth && !gd.layout.width) ? '100%' : fullLayout.width + 'px',
58+
height: (gd._context.responsive && fullLayout.autosize && !gd._context._hasZeroHeight && !gd.layout.height) ? '100%' : fullLayout.height + 'px'
5959
})
6060
.selectAll('.main-svg')
6161
.call(Drawing.setSize, fullLayout.width, fullLayout.height);

src/plots/polar/layout_defaults.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
var Lib = require('../../lib');
1212
var Color = require('../../components/color');
13+
var Template = require('../../plot_api/plot_template');
14+
1315
var handleSubplotDefaults = require('../subplot_defaults');
1416
var getSubplotData = require('../get_data').getSubplotData;
1517

@@ -49,11 +51,7 @@ function handleDefaults(contIn, contOut, coerce, opts) {
4951
}
5052

5153
var axIn = contIn[axName];
52-
// Note: does not need template propagation, since coerceAxis is still
53-
// based on the subplot-wide coerce function. Though it may be more
54-
// efficient to make a new coerce function, then we *would* need to
55-
// propagate the template.
56-
var axOut = contOut[axName] = {};
54+
var axOut = Template.newContainer(contOut, axName);
5755
axOut._id = axOut._name = axName;
5856
axOut._traceIndices = subplotData.map(function(t) { return t._expandedIndex; });
5957

src/traces/carpet/ab_defaults.js

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

1111
var handleAxisDefaults = require('./axis_defaults');
12+
var Template = require('../../plot_api/plot_template');
1213

1314
module.exports = function handleABDefaults(traceIn, traceOut, fullLayout, coerce, dfltColor) {
1415
var a = coerce('a');
@@ -34,7 +35,7 @@ function mimickAxisDefaults(traceIn, traceOut, fullLayout, dfltColor) {
3435
axesList.forEach(function(axName) {
3536
var axLetter = axName.charAt(0);
3637
var axIn = traceIn[axName] || {};
37-
var axOut = {};
38+
var axOut = Template.newContainer(traceOut, axName);
3839

3940
var defaultOptions = {
4041
tickfont: 'x',
@@ -50,11 +51,8 @@ function mimickAxisDefaults(traceIn, traceOut, fullLayout, dfltColor) {
5051
};
5152

5253
handleAxisDefaults(axIn, axOut, defaultOptions);
53-
5454
axOut._categories = axOut._categories || [];
5555

56-
traceOut[axName] = axOut;
57-
5856
// so we don't have to repeat autotype unnecessarily,
5957
// copy an autotype back to traceIn
6058
if(!traceIn[axName] && axIn.type !== '-') {

src/traces/scatter/link_traces.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,16 @@ module.exports = function linkTraces(gd, plotinfo, cdscatter) {
7575
}
7676
}
7777

78+
if(trace.fill && (
79+
trace.fill.substr(0, 6) === 'tozero' || trace.fill === 'toself' ||
80+
(trace.fill.substr(0, 2) === 'to' && !trace._prevtrace))
81+
) {
82+
trace._ownfill = true;
83+
}
84+
7885
prevtraces[group] = trace;
7986
} else {
80-
trace._prevtrace = trace._nexttrace = null;
87+
trace._prevtrace = trace._nexttrace = trace._ownfill = null;
8188
}
8289
}
8390

src/traces/scatter/plot.js

+3-12
Original file line numberDiff line numberDiff line change
@@ -93,19 +93,10 @@ function createFills(gd, traceJoin, plotinfo) {
9393
var trace = d[0].trace;
9494

9595
var fillData = [];
96-
if(trace.fill && (trace.fill.substr(0, 6) === 'tozero' || trace.fill === 'toself' ||
97-
(trace.fill.substr(0, 2) === 'to' && !trace._prevtrace))
98-
) {
99-
fillData = ['_ownFill'];
100-
}
101-
if(trace._nexttrace) {
102-
// make the fill-to-next path now for the NEXT trace, so it shows
103-
// behind both lines.
104-
fillData.push('_nextFill');
105-
}
96+
if(trace._ownfill) fillData.push('_ownFill');
97+
if(trace._nexttrace) fillData.push('_nextFill');
10698

107-
var fillJoin = fills.selectAll('g')
108-
.data(fillData, identity);
99+
var fillJoin = fills.selectAll('g').data(fillData, identity);
109100

110101
fillJoin.enter().append('g');
111102

src/traces/scattergl/attributes.js

+11
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,17 @@ var attrs = module.exports = overrideAll({
4646
line: {
4747
color: scatterLineAttrs.color,
4848
width: scatterLineAttrs.width,
49+
shape: {
50+
valType: 'enumerated',
51+
values: ['linear', 'hv', 'vh', 'hvh', 'vhv'],
52+
dflt: 'linear',
53+
role: 'style',
54+
editType: 'plot',
55+
description: [
56+
'Determines the line shape.',
57+
'The values correspond to step-wise line shapes.'
58+
].join(' ')
59+
},
4960
dash: {
5061
valType: 'enumerated',
5162
values: Object.keys(DASHES),

src/traces/scattergl/convert.js

+65-21
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,8 @@ function getSymbolSdf(symbol) {
385385
}
386386

387387
function convertLinePositions(gd, trace, positions) {
388-
var count = positions.length / 2;
388+
var len = positions.length;
389+
var count = len / 2;
389390
var linePositions;
390391
var i;
391392

@@ -394,38 +395,81 @@ function convertLinePositions(gd, trace, positions) {
394395
linePositions = [];
395396
for(i = 0; i < count - 1; i++) {
396397
if(isNaN(positions[i * 2]) || isNaN(positions[i * 2 + 1])) {
397-
linePositions.push(NaN);
398-
linePositions.push(NaN);
399-
linePositions.push(NaN);
400-
linePositions.push(NaN);
398+
linePositions.push(NaN, NaN, NaN, NaN);
399+
} else {
400+
linePositions.push(positions[i * 2], positions[i * 2 + 1]);
401+
if(!isNaN(positions[i * 2 + 2]) && !isNaN(positions[i * 2 + 3])) {
402+
linePositions.push(positions[i * 2 + 2], positions[i * 2 + 1]);
403+
} else {
404+
linePositions.push(NaN, NaN);
405+
}
406+
}
407+
}
408+
linePositions.push(positions[len - 2], positions[len - 1]);
409+
} else if(trace.line.shape === 'hvh') {
410+
linePositions = [];
411+
for(i = 0; i < count - 1; i++) {
412+
if(isNaN(positions[i * 2]) || isNaN(positions[i * 2 + 1]) || isNaN(positions[i * 2 + 2]) || isNaN(positions[i * 2 + 3])) {
413+
if(!isNaN(positions[i * 2]) && !isNaN(positions[i * 2 + 1])) {
414+
linePositions.push(positions[i * 2], positions[i * 2 + 1]);
415+
} else {
416+
linePositions.push(NaN, NaN);
417+
}
418+
linePositions.push(NaN, NaN);
401419
}
402420
else {
403-
linePositions.push(positions[i * 2]);
404-
linePositions.push(positions[i * 2 + 1]);
405-
linePositions.push(positions[i * 2 + 2]);
406-
linePositions.push(positions[i * 2 + 1]);
421+
var midPtX = (positions[i * 2] + positions[i * 2 + 2]) / 2;
422+
linePositions.push(
423+
positions[i * 2],
424+
positions[i * 2 + 1],
425+
midPtX,
426+
positions[i * 2 + 1],
427+
midPtX,
428+
positions[i * 2 + 3]
429+
);
407430
}
408431
}
409-
linePositions.push(positions[positions.length - 2]);
410-
linePositions.push(positions[positions.length - 1]);
432+
linePositions.push(positions[len - 2], positions[len - 1]);
433+
} else if(trace.line.shape === 'vhv') {
434+
linePositions = [];
435+
for(i = 0; i < count - 1; i++) {
436+
if(isNaN(positions[i * 2]) || isNaN(positions[i * 2 + 1]) || isNaN(positions[i * 2 + 2]) || isNaN(positions[i * 2 + 3])) {
437+
if(!isNaN(positions[i * 2]) && !isNaN(positions[i * 2 + 1])) {
438+
linePositions.push(positions[i * 2], positions[i * 2 + 1]);
439+
} else {
440+
linePositions.push(NaN, NaN);
441+
}
442+
linePositions.push(NaN, NaN);
443+
}
444+
else {
445+
var midPtY = (positions[i * 2 + 1] + positions[i * 2 + 3]) / 2;
446+
linePositions.push(
447+
positions[i * 2],
448+
positions[i * 2 + 1],
449+
positions[i * 2],
450+
midPtY,
451+
positions[i * 2 + 2],
452+
midPtY
453+
);
454+
}
455+
}
456+
linePositions.push(positions[len - 2], positions[len - 1]);
411457
} else if(trace.line.shape === 'vh') {
412458
linePositions = [];
413459
for(i = 0; i < count - 1; i++) {
414460
if(isNaN(positions[i * 2]) || isNaN(positions[i * 2 + 1])) {
415-
linePositions.push(NaN);
416-
linePositions.push(NaN);
417-
linePositions.push(NaN);
418-
linePositions.push(NaN);
461+
linePositions.push(NaN, NaN, NaN, NaN);
419462
}
420463
else {
421-
linePositions.push(positions[i * 2]);
422-
linePositions.push(positions[i * 2 + 1]);
423-
linePositions.push(positions[i * 2]);
424-
linePositions.push(positions[i * 2 + 3]);
464+
linePositions.push(positions[i * 2], positions[i * 2 + 1]);
465+
if(!isNaN(positions[i * 2 + 2]) && !isNaN(positions[i * 2 + 3])) {
466+
linePositions.push(positions[i * 2], positions[i * 2 + 3]);
467+
} else {
468+
linePositions.push(NaN, NaN);
469+
}
425470
}
426471
}
427-
linePositions.push(positions[positions.length - 2]);
428-
linePositions.push(positions[positions.length - 1]);
472+
linePositions.push(positions[len - 2], positions[len - 1]);
429473
} else {
430474
linePositions = positions;
431475
}

src/traces/scattergl/defaults.js

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
4242
if(subTypes.hasLines(traceOut)) {
4343
coerce('connectgaps');
4444
handleLineDefaults(traceIn, traceOut, defaultColor, layout, coerce);
45+
coerce('line.shape');
4546
}
4647

4748
if(subTypes.hasMarkers(traceOut)) {

0 commit comments

Comments
 (0)