Skip to content

Commit

Permalink
Merge pull request #1 from plotly/master
Browse files Browse the repository at this point in the history
rebase pull or so?
  • Loading branch information
thierryVergult authored Sep 28, 2020
2 parents 86f5e2d + 2cce0e9 commit 8c38995
Show file tree
Hide file tree
Showing 34 changed files with 288 additions and 59 deletions.
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
"gl-select-box": "^1.0.4",
"gl-spikes2d": "^1.0.2",
"gl-streamtube3d": "^1.4.1",
"gl-surface3d": "^1.5.2",
"gl-surface3d": "^1.6.0",
"gl-text": "^1.1.8",
"glslify": "^7.1.1",
"has-hover": "^1.0.1",
Expand All @@ -117,7 +117,7 @@
"strongly-connected-components": "^1.0.1",
"superscript-text": "^1.0.0",
"svg-path-sdf": "^1.1.3",
"tinycolor2": "^1.4.1",
"tinycolor2": "^1.4.2",
"to-px": "1.0.1",
"topojson-client": "^3.1.0",
"webgl-context": "^2.2.0",
Expand Down
1 change: 1 addition & 0 deletions src/components/colorbar/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ module.exports = overrideAll({
showticksuffix: axesAttrs.showticksuffix,
separatethousands: axesAttrs.separatethousands,
exponentformat: axesAttrs.exponentformat,
minexponent: axesAttrs.minexponent,
showexponent: axesAttrs.showexponent,
title: {
text: {
Expand Down
1 change: 1 addition & 0 deletions src/components/colorbar/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,7 @@ function mockColorBarAxis(gd, opts, zrange) {
tickangle: opts.tickangle,
tickformat: opts.tickformat,
exponentformat: opts.exponentformat,
minexponent: opts.minexponent,
separatethousands: opts.separatethousands,
showexponent: opts.showexponent,
showtickprefix: opts.showtickprefix,
Expand Down
2 changes: 0 additions & 2 deletions src/components/legend/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ module.exports = function draw(gd, opts) {
if(title.text) {
var titleEl = Lib.ensureSingle(scrollBox, 'text', 'legendtitletext');
titleEl.attr('text-anchor', 'start')
.classed('user-select-none', true)
.call(Drawing.font, title.font)
.text(title.text);

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

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

Expand Down
3 changes: 1 addition & 2 deletions src/components/rangeselector/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,7 @@ function drawButtonText(button, selectorLayout, d, gd) {
}

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

text.call(Drawing.font, selectorLayout.font)
Expand Down
18 changes: 8 additions & 10 deletions src/components/sliders/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,10 @@ function drawCurrentValue(sliderGroup, sliderOpts, valueOverride) {
}

var text = Lib.ensureSingle(sliderGroup, 'text', constants.labelClass, function(s) {
s.classed('user-select-none', true)
.attr({
'text-anchor': textAnchor,
'data-notex': 1
});
s.attr({
'text-anchor': textAnchor,
'data-notex': 1
});
});

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

function drawLabel(item, data, sliderOpts) {
var text = Lib.ensureSingle(item, 'text', constants.labelClass, function(s) {
s.classed('user-select-none', true)
.attr({
'text-anchor': 'middle',
'data-notex': 1
});
s.attr({
'text-anchor': 'middle',
'data-notex': 1
});
});

var tx = data.step.label;
Expand Down
12 changes: 5 additions & 7 deletions src/components/updatemenus/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,7 @@ function drawHeader(gd, gHeader, gButton, scrollBox, menuOpts) {

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

function drawItemText(item, menuOpts, itemOpts, gd) {
var text = Lib.ensureSingle(item, 'text', constants.itemTextClassName, function(s) {
s.classed('user-select-none', true)
.attr({
'text-anchor': 'start',
'data-notex': 1
});
s.attr({
'text-anchor': 'start',
'data-notex': 1
});
});

var tx = itemOpts.label;
Expand Down
11 changes: 4 additions & 7 deletions src/lib/gl_format_color.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,19 @@ function formatColor(containerIn, opacityIn, len) {
return colorOut;
}

function parseColorScale(cont, alpha) {
if(alpha === undefined) alpha = 1;

function parseColorScale(cont) {
var cOpts = Colorscale.extractOpts(cont);

var colorscale = cOpts.reversescale ?
Colorscale.flipScale(cOpts.colorscale) :
cOpts.colorscale;
var colorscale = cOpts.colorscale;
if(cOpts.reversescale) colorscale = Colorscale.flipScale(cOpts.colorscale);

return colorscale.map(function(elem) {
var index = elem[0];
var color = tinycolor(elem[1]);
var rgb = color.toRgb();
return {
index: index,
rgb: [rgb.r, rgb.g, rgb.b, alpha]
rgb: [rgb.r, rgb.g, rgb.b, rgb.a]
};
});
}
Expand Down
4 changes: 3 additions & 1 deletion src/plot_api/plot_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -3717,13 +3717,15 @@ function makePlotFramework(gd) {

// Plot container
fullLayout._container = gd3.selectAll('.plot-container').data([0]);
fullLayout._container.enter().insert('div', ':first-child')
fullLayout._container.enter()
.insert('div', ':first-child')
.classed('plot-container', true)
.classed('plotly', true);

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

Expand Down
4 changes: 3 additions & 1 deletion src/plots/cartesian/axes.js
Original file line number Diff line number Diff line change
Expand Up @@ -1103,7 +1103,8 @@ function autoTickRound(ax) {

var maxend = Math.max(Math.abs(rng[0]), Math.abs(rng[1]));
var rangeexp = Math.floor(Math.log(maxend) / Math.LN10 + 0.01);
if(Math.abs(rangeexp) > 3) {
var minexponent = ax.minexponent === undefined ? 3 : ax.minexponent;
if(Math.abs(rangeexp) > minexponent) {
if(isSIFormat(ax.exponentformat) && !beyondSI(rangeexp)) {
ax._tickexponent = 3 * Math.round((rangeexp - 1) / 3);
} else ax._tickexponent = rangeexp;
Expand Down Expand Up @@ -1586,6 +1587,7 @@ function numFormat(v, ax, fmtoverride, hover) {
// make a dummy axis obj to get the auto rounding and exponent
var ah = {
exponentformat: exponentFormat,
minexponent: ax.minexponent,
dtick: ax.showexponent === 'none' ? ax.dtick :
(isNumeric(v) ? Math.abs(v) || 1 : 1),
// if not showing any exponents, don't change the exponent
Expand Down
11 changes: 11 additions & 0 deletions src/plots/cartesian/layout_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,17 @@ module.exports = {
'If *B*, 1B.'
].join(' ')
},
minexponent: {
valType: 'number',
dflt: 3,
min: 0,
role: 'style',
editType: 'ticks',
description: [
'Hide SI prefix for 10^n if |n| is below this number.',
'This only has an effect when `tickformat` is *SI* or *B*.'
].join(' ')
},
separatethousands: {
valType: 'boolean',
dflt: false,
Expand Down
1 change: 1 addition & 0 deletions src/plots/cartesian/tick_label_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ function handleOtherDefaults(containerIn, containerOut, coerce, axType, options)
if(!tickFormat && axType !== 'date') {
coerce('showexponent', showAttrDflt);
coerce('exponentformat');
coerce('minexponent');
coerce('separatethousands');
}
}
Expand Down
5 changes: 0 additions & 5 deletions src/plots/gl2d/scene2d.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,6 @@ proto.makeFramework = function() {

this.updateSize(canvas);

// disabling user select on the canvas
// sanitizes double-clicks interactions
// ref: https://github.com/plotly/plotly.js/issues/744
canvas.className += ' user-select-none';

// create SVG container for hover text
var svgContainer = this.svgContainer = document.createElementNS(
'http://www.w3.org/2000/svg',
Expand Down
1 change: 1 addition & 0 deletions src/plots/gl3d/layout/axis_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ module.exports = overrideAll({
showticksuffix: axesAttrs.showticksuffix,
showexponent: axesAttrs.showexponent,
exponentformat: axesAttrs.exponentformat,
minexponent: axesAttrs.minexponent,
separatethousands: axesAttrs.separatethousands,
tickformat: axesAttrs.tickformat,
tickformatstops: axesAttrs.tickformatstops,
Expand Down
1 change: 1 addition & 0 deletions src/plots/polar/layout_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ var axisTickAttrs = overrideAll({
ticksuffix: axesAttrs.ticksuffix,
showexponent: axesAttrs.showexponent,
exponentformat: axesAttrs.exponentformat,
minexponent: axesAttrs.minexponent,
separatethousands: axesAttrs.separatethousands,
tickfont: axesAttrs.tickfont,
tickangle: axesAttrs.tickangle,
Expand Down
1 change: 1 addition & 0 deletions src/plots/ternary/layout_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ var ternaryAxesAttrs = {
ticksuffix: axesAttrs.ticksuffix,
showexponent: axesAttrs.showexponent,
exponentformat: axesAttrs.exponentformat,
minexponent: axesAttrs.minexponent,
separatethousands: axesAttrs.separatethousands,
tickfont: axesAttrs.tickfont,
tickangle: axesAttrs.tickangle,
Expand Down
10 changes: 10 additions & 0 deletions src/traces/carpet/axis_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,16 @@ module.exports = {
'If *B*, 1B.'
].join(' ')
},
minexponent: {
valType: 'number',
dflt: 3,
min: 0,
role: 'style',
editType: 'calc',
description: [
'Hide SI prefix for 10^n if |n| is below this number'
].join(' ')
},
separatethousands: {
valType: 'boolean',
dflt: false,
Expand Down
2 changes: 2 additions & 0 deletions src/traces/carpet/axis_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, options)
coerce('separatethousands');
coerce('tickformat');
coerce('exponentformat');
coerce('minexponent');
coerce('showexponent');
coerce('categoryorder');

Expand Down Expand Up @@ -186,6 +187,7 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, options)
delete containerOut.tickangle;
delete containerOut.showexponent;
delete containerOut.exponentformat;
delete containerOut.minexponent;
delete containerOut.tickformat;
delete containerOut.showticksuffix;
delete containerOut.showtickprefix;
Expand Down
1 change: 0 additions & 1 deletion src/traces/carpet/plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ function drawAxisTitle(gd, layer, trace, t, xy, dxy, axis, xa, ya, labelOrientat
'rotate(' + orientation.angle + ') ' +
'translate(0,' + offset + ')'
)
.classed('user-select-none', true)
.attr('text-anchor', 'middle')
.call(Drawing.font, axis.title.font);
});
Expand Down
1 change: 1 addition & 0 deletions src/traces/indicator/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ module.exports = {
showticksuffix: axesAttrs.showticksuffix,
separatethousands: axesAttrs.separatethousands,
exponentformat: axesAttrs.exponentformat,
minexponent: axesAttrs.minexponent,
showexponent: axesAttrs.showexponent,
editType: 'plot'
}, 'plot'),
Expand Down
7 changes: 2 additions & 5 deletions src/traces/parcoords/parcoords.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,7 @@ function styleExtentTexts(selection) {
selection
.classed(c.cn.axisExtentText, true)
.attr('text-anchor', 'middle')
.style('cursor', 'default')
.style('user-select', 'none');
.style('cursor', 'default');
}

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

axis.selectAll('text')
.style('text-shadow', '1px 1px 1px #fff, -1px -1px 1px #fff, 1px -1px 1px #fff, -1px 1px 1px #fff')
.style('cursor', 'default')
.style('user-select', 'none');
.style('cursor', 'default');

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

axisTitle
Expand Down
1 change: 0 additions & 1 deletion src/traces/sankey/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,6 @@ module.exports = function(gd, svg, calcData, layout, callbacks) {
.append('text')
.classed(c.cn.nodeLabel, true)
.attr('transform', textFlip)
.style('user-select', 'none')
.style('cursor', 'default')
.style('fill', 'black');

Expand Down
1 change: 1 addition & 0 deletions src/traces/sunburst/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ module.exports = {
'this option won\'t have any effect and `insidetextfont` would be used.'
].join(' ')
}),
sort: pieAttrs.sort,

domain: domainAttrs({name: 'sunburst', trace: true, editType: 'calc'})
};
4 changes: 3 additions & 1 deletion src/traces/sunburst/calc.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,9 @@ exports.calc = function(gd, trace) {
if(failed) return;

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

var pullColor;
var scaleColor;
Expand Down
2 changes: 2 additions & 0 deletions src/traces/sunburst/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout

coerce('insidetextorientation');

coerce('sort');

handleDomainDefaults(traceOut, layout, coerce);

// do not support transforms for now
Expand Down
Loading

0 comments on commit 8c38995

Please sign in to comment.