Skip to content

Commit a0220ac

Browse files
authored
Merge branch 'main' into domainpad
2 parents 7df721e + f752b3e commit a0220ac

42 files changed

Lines changed: 467 additions & 125 deletions

Some content is hidden

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

‎draftlogs/7826_fix.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Respect explicit `node.x`/`node.y` positions in Sankey traces that contain unlinked or grouped nodes [[#7826](https://github.com/plotly/plotly.js/pull/7826)], with thanks to @kyo5uke for the contribution!

‎draftlogs/8071_fix.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Fix numeric and numeric-string marker symbol variant detection in `scattergl` [[#8071](https://github.com/plotly/plotly.js/pull/8071)]

‎draftlogs/8139_fix.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Fix funnel `percentTotal` text formatting to display formatted percentages instead of raw ratios [[#8139](https://github.com/plotly/plotly.js/pull/8139)], with thanks to @ORITOMI for the contribution!

‎draftlogs/8145_add.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Add TypeScript declarations for lifecycle and WebGL context events [[#8145](https://github.com/plotly/plotly.js/pull/8145)]

‎lib/index.d.ts‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,28 +81,37 @@ export type {
8181

8282
export type {
8383
BeforePlotEvent,
84+
ButtonClickedEvent,
8485
ClickAnnotationEvent,
8586
FrameAnimationEvent,
87+
IcicleClickEvent,
88+
IciclePlotDatum,
8689
LegendClickEvent,
90+
LegendTitleClickEvent,
8791
PlotCoordinate,
8892
PlotDatum,
8993
PlotHoverEvent,
9094
PlotlyEventName,
9195
PlotlyHTMLElement,
9296
PlotMouseEvent,
97+
PlotReactEvent,
9398
PlotRelayoutEvent,
9499
PlotRestyleEvent,
95100
PlotRestyleEventUpdate,
96101
PlotScatterDataPoint,
97102
PlotScene,
98103
PlotSelectedData,
99104
PlotSelectionEvent,
105+
PlotUpdateEvent,
100106
SelectionRange,
101107
SliderChangeEvent,
102108
SliderEndEvent,
103109
SliderStartEvent,
104110
SunburstClickEvent,
105-
SunburstPlotDatum
111+
SunburstPlotDatum,
112+
TreemapClickEvent,
113+
TreemapPlotDatum,
114+
WebGLContextLostEvent
106115
} from '../src/types/core/events';
107116

108117
// ---------------------------------------------------------------------------

‎src/traces/bar/plot.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1107,7 +1107,7 @@ function calcTexttemplate(fullLayout, cd, index, xa, ya) {
11071107
obj.percentPrevious = cdi.difR;
11081108
obj.percentPreviousLabel = Lib.formatPercent(cdi.difR);
11091109
obj.percentTotal = cdi.sumR;
1110-
obj.percenTotalLabel = Lib.formatPercent(cdi.sumR);
1110+
obj.percentTotalLabel = Lib.formatPercent(cdi.sumR);
11111111
}
11121112

11131113
var customdata = Lib.castOption(trace, cdi.i, 'customdata');

‎src/traces/sankey/render.js‎

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -261,15 +261,23 @@ function sankeyModel(layout, d, traceIndex) {
261261

262262
// Force node position
263263
if(trace.node.x.length && trace.node.y.length) {
264-
for(i = 0; i < Math.min(trace.node.x.length, trace.node.y.length, graph.nodes.length); i++) {
265-
if(trace.node.x[i] && trace.node.y[i]) {
266-
var pos = [trace.node.x[i] * width, trace.node.y[i] * height];
267-
graph.nodes[i].x0 = pos[0] - nodeThickness / 2;
268-
graph.nodes[i].x1 = pos[0] + nodeThickness / 2;
269-
270-
var nodeHeight = graph.nodes[i].y1 - graph.nodes[i].y0;
271-
graph.nodes[i].y0 = pos[1] - nodeHeight / 2;
272-
graph.nodes[i].y1 = pos[1] + nodeHeight / 2;
264+
// graph.nodes omits unlinked nodes and may have transient group
265+
// children unshifted to its front, so its order does not match
266+
// trace.node.x/y. Index the explicit positions by each node's
267+
// original pointNumber rather than by array position.
268+
for(i = 0; i < graph.nodes.length; i++) {
269+
var forcedNode = graph.nodes[i];
270+
if(forcedNode.partOfGroup) continue;
271+
272+
var p = forcedNode.pointNumber;
273+
if (trace.node.x[p] && trace.node.y[p]) {
274+
var pos = [trace.node.x[p] * width, trace.node.y[p] * height];
275+
forcedNode.x0 = pos[0] - nodeThickness / 2;
276+
forcedNode.x1 = pos[0] + nodeThickness / 2;
277+
278+
var nodeHeight = forcedNode.y1 - forcedNode.y0;
279+
forcedNode.y0 = pos[1] - nodeHeight / 2;
280+
forcedNode.y1 = pos[1] + nodeHeight / 2;
273281
}
274282
}
275283
if(trace.arrangement === 'snap') {
@@ -825,13 +833,13 @@ function snappingForce(sankeyNode, forceKey, nodes, d) {
825833
// basic data utilities
826834

827835
function persistFinalNodePositions(d, gd) {
828-
var x = [];
829-
var y = [];
830-
for(var i = 0; i < d.graph.nodes.length; i++) {
831-
var nodeX = (d.graph.nodes[i].x0 + d.graph.nodes[i].x1) / 2;
832-
var nodeY = (d.graph.nodes[i].y0 + d.graph.nodes[i].y1) / 2;
833-
x.push(nodeX / d.figure.width);
834-
y.push(nodeY / d.figure.height);
836+
// Write by pointNumber because graph.nodes omits unlinked nodes
837+
const x = [...d.trace.node.x];
838+
const y = [...d.trace.node.y];
839+
for (const node of d.graph.nodes) {
840+
if (node.partOfGroup) continue;
841+
x[node.pointNumber] = (node.x0 + node.x1) / 2 / d.figure.width;
842+
y[node.pointNumber] = (node.y0 + node.y1) / 2 / d.figure.height;
835843
}
836844
Registry.call('_guiRestyle', gd, {
837845
'node.x': [x],
@@ -1110,4 +1118,4 @@ module.exports = function(gd, svg, calcData, layout, callbacks) {
11101118
nodeLabel
11111119
.transition()
11121120
.ease(c.ease).duration(c.duration);
1113-
};
1121+
};

‎src/traces/scattergl/constants.ts‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ export const SYMBOL_SDF_SIZE = 200;
66
export const SYMBOL_SIZE = 20;
77
export const SYMBOL_STROKE = SYMBOL_SIZE / 20;
88

9-
export const DOT_RE = /-dot/;
10-
export const OPEN_RE = /-open/;
11-
129
export const DASHES = {
1310
solid: [1],
1411
dot: [1, 1],

‎src/traces/scattergl/helpers.js‎

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11
'use strict';
22

3-
var constants = require('./constants');
3+
const { symbolNumber } = require('../../components/drawing');
44

5-
exports.isOpenSymbol = function(symbol) {
6-
return (typeof symbol === 'string') ?
7-
constants.OPEN_RE.test(symbol) :
8-
symbol % 200 > 100;
9-
};
5+
exports.isOpenSymbol = (symbol) => symbolNumber(symbol) % 200 >= 100;
106

11-
exports.isDotSymbol = function(symbol) {
12-
return (typeof symbol === 'string') ?
13-
constants.DOT_RE.test(symbol) :
14-
symbol > 200;
15-
};
7+
exports.isDotSymbol = (symbol) => symbolNumber(symbol) >= 200;

0 commit comments

Comments
 (0)