Skip to content

Commit 2802d22

Browse files
committed
Merge branch 'master' into registry-use-component
2 parents a1ea365 + 7e2448e commit 2802d22

39 files changed

+475
-99
lines changed

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ We use the following [labels](https://github.com/plotly/plotly.js/labels) to tra
1717
| `type: bug` | bug report confirmed by a plotly team member |
1818
| `type: feature` | planned feature additions |
1919
| `type: performance` | performance related tasks |
20-
| `type: maintenace` | source code cleanup resulting in no enhancement for users |
20+
| `type: maintenance` | source code cleanup resulting in no enhancement for users |
2121
| `type: documentation` | API doc or attribute description improvements |
2222
| `type: community` | issue left open for community input and pull requests |
2323
| `type: duplicate` | *self-explanatory* |

circle.yml

+2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ dependencies:
1313
pre:
1414
- docker pull plotly/testbed:latest
1515
post:
16+
- eval $(node tasks/run_docker.js)
1617
- npm run cibuild
1718
- npm run pretest
19+
- eval $(node tasks/setup_docker.js)
1820

1921
test:
2022
override:

src/components/colorbar/attributes.js

+1
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ module.exports = {
167167
showtickprefix: axesAttrs.showtickprefix,
168168
ticksuffix: axesAttrs.ticksuffix,
169169
showticksuffix: axesAttrs.showticksuffix,
170+
separatethousands: axesAttrs.separatethousands,
170171
exponentformat: axesAttrs.exponentformat,
171172
showexponent: axesAttrs.showexponent,
172173
title: {

src/components/colorbar/draw.js

+1
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ module.exports = function draw(gd, id) {
159159
tickangle: opts.tickangle,
160160
tickformat: opts.tickformat,
161161
exponentformat: opts.exponentformat,
162+
separatethousands: opts.separatethousands,
162163
showexponent: opts.showexponent,
163164
showtickprefix: opts.showtickprefix,
164165
tickprefix: opts.tickprefix,

src/components/images/draw.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
var d3 = require('d3');
1212
var Drawing = require('../drawing');
1313
var Axes = require('../../plots/cartesian/axes');
14+
var xmlnsNamespaces = require('../../constants/xmlns_namespaces');
1415

1516
module.exports = function draw(gd) {
1617

@@ -52,9 +53,10 @@ module.exports = function draw(gd) {
5253

5354
// Images must be converted to dataURL's for exporting.
5455
function setImage(d) {
55-
5656
var thisImage = d3.select(this);
5757

58+
thisImage.attr('xmlns', xmlnsNamespaces.svg);
59+
5860
var imagePromise = new Promise(function(resolve) {
5961

6062
var img = new Image();
@@ -92,7 +94,6 @@ module.exports = function draw(gd) {
9294
}
9395

9496
function applyAttributes(d) {
95-
9697
var thisImage = d3.select(this);
9798

9899
// Axes if specified
@@ -140,7 +141,9 @@ module.exports = function draw(gd) {
140141
yId = yref ? yref._id : '',
141142
clipAxes = xId + yId;
142143

143-
thisImage.call(Drawing.setClipUrl, 'clip' + fullLayout._uid + clipAxes);
144+
if(clipAxes) {
145+
thisImage.call(Drawing.setClipUrl, 'clip' + fullLayout._uid + clipAxes);
146+
}
144147
}
145148

146149

src/lib/index.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -584,15 +584,21 @@ lib.objectFromPath = function(path, value) {
584584
* // returns '2016'
585585
*
586586
* @example
587+
* lib.numSeparate(3000, '.,', true);
588+
* // returns '3,000'
589+
*
590+
* @example
587591
* lib.numSeparate(1234.56, '|,')
588592
* // returns '1,234|56'
589593
*
590594
* @param {string|number} value the value to be converted
591595
* @param {string} separators string of decimal, then thousands separators
596+
* @param {boolean} separatethousands boolean, 4-digit integers are separated if true
592597
*
593598
* @return {string} the value that has been separated
594599
*/
595-
lib.numSeparate = function(value, separators) {
600+
lib.numSeparate = function(value, separators, separatethousands) {
601+
if(!separatethousands) separatethousands = false;
596602

597603
if(typeof separators !== 'string' || separators.length === 0) {
598604
throw new Error('Separator string required for formatting!');
@@ -611,7 +617,7 @@ lib.numSeparate = function(value, separators) {
611617
x2 = x.length > 1 ? decimalSep + x[1] : '';
612618

613619
// Years are ignored for thousands separators
614-
if(thouSep && (x.length > 1 || x1.length > 4)) {
620+
if(thouSep && (x.length > 1 || x1.length > 4 || separatethousands)) {
615621
while(thousandsRe.test(x1)) {
616622
x1 = x1.replace(thousandsRe, '$1' + thouSep + '$2');
617623
}

src/plot_api/plot_api.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1747,6 +1747,8 @@ Plotly.restyle = function restyle(gd, astr, val, traces) {
17471747
oldVal = param.get();
17481748
newVal = Array.isArray(vi) ? vi[i % vi.length] : vi;
17491749

1750+
if(newVal === undefined) continue;
1751+
17501752
// setting bin or z settings should turn off auto
17511753
// and setting auto should save bin or z settings
17521754
if(zscl.indexOf(ai) !== -1) {
@@ -2039,7 +2041,7 @@ Plotly.restyle = function restyle(gd, astr, val, traces) {
20392041
if(!plotDone || !plotDone.then) plotDone = Promise.resolve();
20402042

20412043
return plotDone.then(function() {
2042-
gd.emit('plotly_restyle', Lib.extendDeep([], [redoit, traces]));
2044+
gd.emit('plotly_restyle', Lib.extendDeepNoArrays([], [redoit, traces]));
20432045
return gd;
20442046
});
20452047
};
@@ -2182,6 +2184,8 @@ Plotly.relayout = function relayout(gd, astr, val) {
21822184
parentFull = Lib.nestedProperty(fullLayout, ptrunk).get(),
21832185
diff;
21842186

2187+
if(vi === undefined) continue;
2188+
21852189
redoit[ai] = vi;
21862190

21872191
// axis reverse is special - it is its own inverse

src/plot_api/plot_config.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,11 @@ module.exports = {
9494

9595
// Turn all console logging on or off (errors will be thrown)
9696
// This should ONLY be set via Plotly.setPlotConfig
97-
logging: false
97+
logging: false,
98+
99+
// Set global transform to be applied to all traces with no
100+
// specification needed
101+
globalTransforms: []
98102
};
99103

100104
// where and how the background gets set can be overridden by context

src/plots/attributes.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,13 @@ module.exports = {
7272
valType: 'flaglist',
7373
role: 'info',
7474
flags: ['x', 'y', 'z', 'text', 'name'],
75-
extras: ['all', 'none'],
75+
extras: ['all', 'none', 'skip'],
7676
dflt: 'all',
77-
description: 'Determines which trace information appear on hover.'
77+
description: [
78+
'Determines which trace information appear on hover.',
79+
'If `none` or `skip` are set, no information is displayed upon hovering.',
80+
'But, if `none` is set, click and hover events are still fired.'
81+
].join(' ')
7882
},
7983
stream: {
8084
token: {

src/plots/cartesian/axes.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1092,7 +1092,8 @@ function numFormat(v, ax, fmtoverride, hover) {
10921092
tickRound = ax._tickround,
10931093
exponentFormat = fmtoverride || ax.exponentformat || 'B',
10941094
exponent = ax._tickexponent,
1095-
tickformat = ax.tickformat;
1095+
tickformat = ax.tickformat,
1096+
separatethousands = ax.separatethousands;
10961097

10971098
// special case for hover: set exponent just for this value, and
10981099
// add a couple more digits of precision over tick labels
@@ -1156,7 +1157,7 @@ function numFormat(v, ax, fmtoverride, hover) {
11561157
if(dp) v = v.substr(0, dp + tickRound).replace(/\.?0+$/, '');
11571158
}
11581159
// insert appropriate decimal point and thousands separator
1159-
v = Lib.numSeparate(v, ax._gd._fullLayout.separators);
1160+
v = Lib.numSeparate(v, ax._gd._fullLayout.separators, separatethousands);
11601161
}
11611162

11621163
// add exponent

src/plots/cartesian/graph_interact.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -394,14 +394,16 @@ function hover(gd, evt, subplot) {
394394
hovermode = 'array';
395395
for(itemnum = 0; itemnum < evt.length; itemnum++) {
396396
cd = gd.calcdata[evt[itemnum].curveNumber||0];
397-
searchData.push(cd);
397+
if(cd[0].trace.hoverinfo !== 'skip') {
398+
searchData.push(cd);
399+
}
398400
}
399401
}
400402
else {
401403
for(curvenum = 0; curvenum < gd.calcdata.length; curvenum++) {
402404
cd = gd.calcdata[curvenum];
403405
trace = cd[0].trace;
404-
if(subplots.indexOf(getSubplot(trace)) !== -1) {
406+
if(trace.hoverinfo !== 'skip' && subplots.indexOf(getSubplot(trace)) !== -1) {
405407
searchData.push(cd);
406408
}
407409
}

src/plots/cartesian/layout_attributes.js

+8
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,14 @@ module.exports = {
305305
'If *B*, 1B.'
306306
].join(' ')
307307
},
308+
separatethousands: {
309+
valType: 'boolean',
310+
dflt: false,
311+
role: 'style',
312+
description: [
313+
'If "true", even 4-digit integers are separated'
314+
].join(' ')
315+
},
308316
tickformat: {
309317
valType: 'string',
310318
dflt: '',

src/plots/cartesian/tick_label_defaults.js

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ module.exports = function handleTickLabelDefaults(containerIn, containerOut, coe
4343
if(!tickFormat && axType !== 'date') {
4444
coerce('showexponent', showAttrDflt);
4545
coerce('exponentformat');
46+
coerce('separatethousands');
4647
}
4748
}
4849
}

src/plots/gl2d/camera.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ function createCamera(scene) {
3232
plot = scene.glplot,
3333
result = new Camera2D(element, plot);
3434

35+
function unSetAutoRange() {
36+
scene.xaxis.autorange = false;
37+
scene.yaxis.autorange = false;
38+
}
39+
3540
result.mouseListener = mouseChange(element, function(buttons, x, y) {
3641
var xrange = scene.xaxis.range,
3742
yrange = scene.yaxis.range,
@@ -84,7 +89,7 @@ function createCamera(scene) {
8489
else if(result.boxEnabled) {
8590
updateRange(xrange, result.boxStart[0], result.boxEnd[0]);
8691
updateRange(yrange, result.boxStart[1], result.boxEnd[1]);
87-
92+
unSetAutoRange();
8893
result.boxEnabled = false;
8994
}
9095
break;
@@ -104,7 +109,7 @@ function createCamera(scene) {
104109
yrange[1] += dy;
105110

106111
result.lastInputTime = Date.now();
107-
112+
unSetAutoRange();
108113
scene.cameraChanged();
109114
}
110115
break;
@@ -142,6 +147,7 @@ function createCamera(scene) {
142147
yrange[1] = (yrange[1] - cy) * scale + cy;
143148

144149
result.lastInputTime = Date.now();
150+
unSetAutoRange();
145151
scene.cameraChanged();
146152
break;
147153
}

0 commit comments

Comments
 (0)