Skip to content

Commit 8c38995

Browse files
Merge pull request #1 from plotly/master
rebase pull or so?
2 parents 86f5e2d + 2cce0e9 commit 8c38995

34 files changed

+288
-59
lines changed

package-lock.json

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
"gl-select-box": "^1.0.4",
9191
"gl-spikes2d": "^1.0.2",
9292
"gl-streamtube3d": "^1.4.1",
93-
"gl-surface3d": "^1.5.2",
93+
"gl-surface3d": "^1.6.0",
9494
"gl-text": "^1.1.8",
9595
"glslify": "^7.1.1",
9696
"has-hover": "^1.0.1",
@@ -117,7 +117,7 @@
117117
"strongly-connected-components": "^1.0.1",
118118
"superscript-text": "^1.0.0",
119119
"svg-path-sdf": "^1.1.3",
120-
"tinycolor2": "^1.4.1",
120+
"tinycolor2": "^1.4.2",
121121
"to-px": "1.0.1",
122122
"topojson-client": "^3.1.0",
123123
"webgl-context": "^2.2.0",

src/components/colorbar/attributes.js

+1
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ module.exports = overrideAll({
173173
showticksuffix: axesAttrs.showticksuffix,
174174
separatethousands: axesAttrs.separatethousands,
175175
exponentformat: axesAttrs.exponentformat,
176+
minexponent: axesAttrs.minexponent,
176177
showexponent: axesAttrs.showexponent,
177178
title: {
178179
text: {

src/components/colorbar/draw.js

+1
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,7 @@ function mockColorBarAxis(gd, opts, zrange) {
683683
tickangle: opts.tickangle,
684684
tickformat: opts.tickformat,
685685
exponentformat: opts.exponentformat,
686+
minexponent: opts.minexponent,
686687
separatethousands: opts.separatethousands,
687688
showexponent: opts.showexponent,
688689
showtickprefix: opts.showtickprefix,

src/components/legend/draw.js

-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ module.exports = function draw(gd, opts) {
8989
if(title.text) {
9090
var titleEl = Lib.ensureSingle(scrollBox, 'text', 'legendtitletext');
9191
titleEl.attr('text-anchor', 'start')
92-
.classed('user-select-none', true)
9392
.call(Drawing.font, title.font)
9493
.text(title.text);
9594

@@ -410,7 +409,6 @@ function drawTexts(g, gd, opts) {
410409
var textEl = Lib.ensureSingle(g, 'text', 'legendtext');
411410

412411
textEl.attr('text-anchor', 'start')
413-
.classed('user-select-none', true)
414412
.call(Drawing.font, opts.font)
415413
.text(isEditable ? ensureLength(name, maxNameLength) : name);
416414

src/components/rangeselector/draw.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,7 @@ function drawButtonText(button, selectorLayout, d, gd) {
144144
}
145145

146146
var text = Lib.ensureSingle(button, 'text', 'selector-text', function(s) {
147-
s.classed('user-select-none', true)
148-
.attr('text-anchor', 'middle');
147+
s.attr('text-anchor', 'middle');
149148
});
150149

151150
text.call(Drawing.font, selectorLayout.font)

src/components/sliders/draw.js

+8-10
Original file line numberDiff line numberDiff line change
@@ -302,11 +302,10 @@ function drawCurrentValue(sliderGroup, sliderOpts, valueOverride) {
302302
}
303303

304304
var text = Lib.ensureSingle(sliderGroup, 'text', constants.labelClass, function(s) {
305-
s.classed('user-select-none', true)
306-
.attr({
307-
'text-anchor': textAnchor,
308-
'data-notex': 1
309-
});
305+
s.attr({
306+
'text-anchor': textAnchor,
307+
'data-notex': 1
308+
});
310309
});
311310

312311
var str = sliderOpts.currentvalue.prefix ? sliderOpts.currentvalue.prefix : '';
@@ -357,11 +356,10 @@ function drawGrip(sliderGroup, gd, sliderOpts) {
357356

358357
function drawLabel(item, data, sliderOpts) {
359358
var text = Lib.ensureSingle(item, 'text', constants.labelClass, function(s) {
360-
s.classed('user-select-none', true)
361-
.attr({
362-
'text-anchor': 'middle',
363-
'data-notex': 1
364-
});
359+
s.attr({
360+
'text-anchor': 'middle',
361+
'data-notex': 1
362+
});
365363
});
366364

367365
var tx = data.step.label;

src/components/updatemenus/draw.js

+5-7
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,7 @@ function drawHeader(gd, gHeader, gButton, scrollBox, menuOpts) {
195195

196196
// draw drop arrow at the right edge
197197
var arrow = Lib.ensureSingle(gHeader, 'text', constants.headerArrowClassName, function(s) {
198-
s.classed('user-select-none', true)
199-
.attr('text-anchor', 'end')
198+
s.attr('text-anchor', 'end')
200199
.call(Drawing.font, menuOpts.font)
201200
.text(constants.arrowSymbol[menuOpts.direction]);
202201
});
@@ -435,11 +434,10 @@ function drawItemRect(item, menuOpts) {
435434

436435
function drawItemText(item, menuOpts, itemOpts, gd) {
437436
var text = Lib.ensureSingle(item, 'text', constants.itemTextClassName, function(s) {
438-
s.classed('user-select-none', true)
439-
.attr({
440-
'text-anchor': 'start',
441-
'data-notex': 1
442-
});
437+
s.attr({
438+
'text-anchor': 'start',
439+
'data-notex': 1
440+
});
443441
});
444442

445443
var tx = itemOpts.label;

src/lib/gl_format_color.js

+4-7
Original file line numberDiff line numberDiff line change
@@ -76,22 +76,19 @@ function formatColor(containerIn, opacityIn, len) {
7676
return colorOut;
7777
}
7878

79-
function parseColorScale(cont, alpha) {
80-
if(alpha === undefined) alpha = 1;
81-
79+
function parseColorScale(cont) {
8280
var cOpts = Colorscale.extractOpts(cont);
8381

84-
var colorscale = cOpts.reversescale ?
85-
Colorscale.flipScale(cOpts.colorscale) :
86-
cOpts.colorscale;
82+
var colorscale = cOpts.colorscale;
83+
if(cOpts.reversescale) colorscale = Colorscale.flipScale(cOpts.colorscale);
8784

8885
return colorscale.map(function(elem) {
8986
var index = elem[0];
9087
var color = tinycolor(elem[1]);
9188
var rgb = color.toRgb();
9289
return {
9390
index: index,
94-
rgb: [rgb.r, rgb.g, rgb.b, alpha]
91+
rgb: [rgb.r, rgb.g, rgb.b, rgb.a]
9592
};
9693
});
9794
}

src/plot_api/plot_api.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -3717,13 +3717,15 @@ function makePlotFramework(gd) {
37173717

37183718
// Plot container
37193719
fullLayout._container = gd3.selectAll('.plot-container').data([0]);
3720-
fullLayout._container.enter().insert('div', ':first-child')
3720+
fullLayout._container.enter()
3721+
.insert('div', ':first-child')
37213722
.classed('plot-container', true)
37223723
.classed('plotly', true);
37233724

37243725
// Make the svg container
37253726
fullLayout._paperdiv = fullLayout._container.selectAll('.svg-container').data([0]);
37263727
fullLayout._paperdiv.enter().append('div')
3728+
.classed('user-select-none', true)
37273729
.classed('svg-container', true)
37283730
.style('position', 'relative');
37293731

src/plots/cartesian/axes.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1103,7 +1103,8 @@ function autoTickRound(ax) {
11031103

11041104
var maxend = Math.max(Math.abs(rng[0]), Math.abs(rng[1]));
11051105
var rangeexp = Math.floor(Math.log(maxend) / Math.LN10 + 0.01);
1106-
if(Math.abs(rangeexp) > 3) {
1106+
var minexponent = ax.minexponent === undefined ? 3 : ax.minexponent;
1107+
if(Math.abs(rangeexp) > minexponent) {
11071108
if(isSIFormat(ax.exponentformat) && !beyondSI(rangeexp)) {
11081109
ax._tickexponent = 3 * Math.round((rangeexp - 1) / 3);
11091110
} else ax._tickexponent = rangeexp;
@@ -1586,6 +1587,7 @@ function numFormat(v, ax, fmtoverride, hover) {
15861587
// make a dummy axis obj to get the auto rounding and exponent
15871588
var ah = {
15881589
exponentformat: exponentFormat,
1590+
minexponent: ax.minexponent,
15891591
dtick: ax.showexponent === 'none' ? ax.dtick :
15901592
(isNumeric(v) ? Math.abs(v) || 1 : 1),
15911593
// if not showing any exponents, don't change the exponent

src/plots/cartesian/layout_attributes.js

+11
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,17 @@ module.exports = {
680680
'If *B*, 1B.'
681681
].join(' ')
682682
},
683+
minexponent: {
684+
valType: 'number',
685+
dflt: 3,
686+
min: 0,
687+
role: 'style',
688+
editType: 'ticks',
689+
description: [
690+
'Hide SI prefix for 10^n if |n| is below this number.',
691+
'This only has an effect when `tickformat` is *SI* or *B*.'
692+
].join(' ')
693+
},
683694
separatethousands: {
684695
valType: 'boolean',
685696
dflt: false,

src/plots/cartesian/tick_label_defaults.js

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ function handleOtherDefaults(containerIn, containerOut, coerce, axType, options)
7272
if(!tickFormat && axType !== 'date') {
7373
coerce('showexponent', showAttrDflt);
7474
coerce('exponentformat');
75+
coerce('minexponent');
7576
coerce('separatethousands');
7677
}
7778
}

src/plots/gl2d/scene2d.js

-5
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,6 @@ proto.makeFramework = function() {
145145

146146
this.updateSize(canvas);
147147

148-
// disabling user select on the canvas
149-
// sanitizes double-clicks interactions
150-
// ref: https://github.com/plotly/plotly.js/issues/744
151-
canvas.className += ' user-select-none';
152-
153148
// create SVG container for hover text
154149
var svgContainer = this.svgContainer = document.createElementNS(
155150
'http://www.w3.org/2000/svg',

src/plots/gl3d/layout/axis_attributes.js

+1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ module.exports = overrideAll({
108108
showticksuffix: axesAttrs.showticksuffix,
109109
showexponent: axesAttrs.showexponent,
110110
exponentformat: axesAttrs.exponentformat,
111+
minexponent: axesAttrs.minexponent,
111112
separatethousands: axesAttrs.separatethousands,
112113
tickformat: axesAttrs.tickformat,
113114
tickformatstops: axesAttrs.tickformatstops,

src/plots/polar/layout_attributes.js

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ var axisTickAttrs = overrideAll({
4747
ticksuffix: axesAttrs.ticksuffix,
4848
showexponent: axesAttrs.showexponent,
4949
exponentformat: axesAttrs.exponentformat,
50+
minexponent: axesAttrs.minexponent,
5051
separatethousands: axesAttrs.separatethousands,
5152
tickfont: axesAttrs.tickfont,
5253
tickangle: axesAttrs.tickangle,

src/plots/ternary/layout_attributes.js

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ var ternaryAxesAttrs = {
4040
ticksuffix: axesAttrs.ticksuffix,
4141
showexponent: axesAttrs.showexponent,
4242
exponentformat: axesAttrs.exponentformat,
43+
minexponent: axesAttrs.minexponent,
4344
separatethousands: axesAttrs.separatethousands,
4445
tickfont: axesAttrs.tickfont,
4546
tickangle: axesAttrs.tickangle,

src/traces/carpet/axis_attributes.js

+10
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,16 @@ module.exports = {
284284
'If *B*, 1B.'
285285
].join(' ')
286286
},
287+
minexponent: {
288+
valType: 'number',
289+
dflt: 3,
290+
min: 0,
291+
role: 'style',
292+
editType: 'calc',
293+
description: [
294+
'Hide SI prefix for 10^n if |n| is below this number'
295+
].join(' ')
296+
},
287297
separatethousands: {
288298
valType: 'boolean',
289299
dflt: false,

src/traces/carpet/axis_defaults.js

+2
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, options)
7878
coerce('separatethousands');
7979
coerce('tickformat');
8080
coerce('exponentformat');
81+
coerce('minexponent');
8182
coerce('showexponent');
8283
coerce('categoryorder');
8384

@@ -186,6 +187,7 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, options)
186187
delete containerOut.tickangle;
187188
delete containerOut.showexponent;
188189
delete containerOut.exponentformat;
190+
delete containerOut.minexponent;
189191
delete containerOut.tickformat;
190192
delete containerOut.showticksuffix;
191193
delete containerOut.showtickprefix;

src/traces/carpet/plot.js

-1
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,6 @@ function drawAxisTitle(gd, layer, trace, t, xy, dxy, axis, xa, ya, labelOrientat
239239
'rotate(' + orientation.angle + ') ' +
240240
'translate(0,' + offset + ')'
241241
)
242-
.classed('user-select-none', true)
243242
.attr('text-anchor', 'middle')
244243
.call(Drawing.font, axis.title.font);
245244
});

src/traces/indicator/attributes.js

+1
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ module.exports = {
355355
showticksuffix: axesAttrs.showticksuffix,
356356
separatethousands: axesAttrs.separatethousands,
357357
exponentformat: axesAttrs.exponentformat,
358+
minexponent: axesAttrs.minexponent,
358359
showexponent: axesAttrs.showexponent,
359360
editType: 'plot'
360361
}, 'plot'),

src/traces/parcoords/parcoords.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,7 @@ function styleExtentTexts(selection) {
350350
selection
351351
.classed(c.cn.axisExtentText, true)
352352
.attr('text-anchor', 'middle')
353-
.style('cursor', 'default')
354-
.style('user-select', 'none');
353+
.style('cursor', 'default');
355354
}
356355

357356
function parcoordsInteractionState() {
@@ -655,8 +654,7 @@ module.exports = function parcoords(gd, cdModule, layout, callbacks) {
655654

656655
axis.selectAll('text')
657656
.style('text-shadow', '1px 1px 1px #fff, -1px -1px 1px #fff, 1px -1px 1px #fff, -1px 1px 1px #fff')
658-
.style('cursor', 'default')
659-
.style('user-select', 'none');
657+
.style('cursor', 'default');
660658

661659
var axisHeading = axisOverlays.selectAll('.' + c.cn.axisHeading)
662660
.data(repeat, keyFun);
@@ -673,7 +671,6 @@ module.exports = function parcoords(gd, cdModule, layout, callbacks) {
673671
.classed(c.cn.axisTitle, true)
674672
.attr('text-anchor', 'middle')
675673
.style('cursor', 'ew-resize')
676-
.style('user-select', 'none')
677674
.style('pointer-events', 'auto');
678675

679676
axisTitle

src/traces/sankey/render.js

-1
Original file line numberDiff line numberDiff line change
@@ -1026,7 +1026,6 @@ module.exports = function(gd, svg, calcData, layout, callbacks) {
10261026
.append('text')
10271027
.classed(c.cn.nodeLabel, true)
10281028
.attr('transform', textFlip)
1029-
.style('user-select', 'none')
10301029
.style('cursor', 'default')
10311030
.style('fill', 'black');
10321031

src/traces/sunburst/attributes.js

+1
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ module.exports = {
203203
'this option won\'t have any effect and `insidetextfont` would be used.'
204204
].join(' ')
205205
}),
206+
sort: pieAttrs.sort,
206207

207208
domain: domainAttrs({name: 'sunburst', trace: true, editType: 'calc'})
208209
};

src/traces/sunburst/calc.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,9 @@ exports.calc = function(gd, trace) {
192192
if(failed) return;
193193

194194
// TODO add way to sort by height also?
195-
hierarchy.sort(function(a, b) { return b.value - a.value; });
195+
if(trace.sort) {
196+
hierarchy.sort(function(a, b) { return b.value - a.value; });
197+
}
196198

197199
var pullColor;
198200
var scaleColor;

src/traces/sunburst/defaults.js

+2
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
7373

7474
coerce('insidetextorientation');
7575

76+
coerce('sort');
77+
7678
handleDomainDefaults(traceOut, layout, coerce);
7779

7880
// do not support transforms for now

0 commit comments

Comments
 (0)