Skip to content

Merge release-v2.35.3 dev branch to master to include recent fixes #7233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 30 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
77591ca
fix to allow you to add fake selections
alexcjohnson Sep 19, 2024
51dcc24
changelog for 7164
alexcjohnson Sep 19, 2024
52975c3
Merge pull request #7164 from plotly/alex/fake-selections
archmoj Sep 19, 2024
92a823f
fix scatterternary with ids attribute
alexcjohnson Sep 20, 2024
573c060
changelog for 7167, and remove errant `fit` in test
alexcjohnson Sep 20, 2024
e7b519b
fix other interaction tests
alexcjohnson Sep 20, 2024
22d8e85
Merge pull request #7167 from plotly/alex/ternary-ids
archmoj Sep 20, 2024
653fe77
draw grids only in the mainplot
archmoj Sep 24, 2024
d390d04
fix issue 7144
archmoj Sep 24, 2024
da926dd
Revert "fix issue 7144"
archmoj Sep 26, 2024
001457c
Revert "draw grids only in the mainplot"
archmoj Sep 26, 2024
b0a2053
ensure grid lines are drawn on main subplot
emilykl Sep 26, 2024
8886e45
correct baseline
archmoj Sep 26, 2024
85934e4
refactor variables
archmoj Sep 26, 2024
4b6a1fd
move block inside
archmoj Sep 26, 2024
5df22a3
simplify if
archmoj Sep 26, 2024
9ede030
set grid layers once
archmoj Sep 26, 2024
cf57b39
use url directly for layout images when not in static mode
alexcjohnson Oct 2, 2024
f913ea4
update map and mapbox baselines
archmoj Sep 27, 2024
ea22a09
Merge pull request #7203 from plotly/baselines-v2.35.3
archmoj Oct 3, 2024
189bce2
fix maplibre source map by using minified bundle
archmoj Oct 3, 2024
7643b5f
add draftlog
archmoj Oct 3, 2024
c999c78
updating year(s) in license
gvwilson Sep 16, 2024
b6f4157
draftlog
archmoj Oct 3, 2024
b48081b
Merge pull request #7205 from plotly/license-v2.35.3
archmoj Oct 3, 2024
9269219
Merge pull request #7204 from plotly/fix7161-mablibre-sourcemap
archmoj Oct 4, 2024
9892ac7
Merge branch 'release-v2.35.3' into alex/direct-images
alexcjohnson Oct 7, 2024
b1fd955
adapt layout images tests to new direct-unless-staticPlot behavior
alexcjohnson Oct 7, 2024
c3454a5
Merge pull request #7199 from plotly/alex/direct-images
archmoj Oct 8, 2024
de644bb
Merge pull request #7171 from plotly/new-fix7144-zorder-overlay
archmoj Oct 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)
MIT License

Copyright (c) 2021 Plotly, Inc
Copyright (c) 2016-2024 Plotly Technologies Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
1 change: 1 addition & 0 deletions draftlogs/7164_fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Allow null or broken selection objects without throwing an error [[#7164](https://github.com/plotly/plotly.js/pull/7164)]
1 change: 1 addition & 0 deletions draftlogs/7167_fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Render scatterternary traces correctly if they have the `ids` attribute [[#7164](https://github.com/plotly/plotly.js/pull/7164)]
1 change: 1 addition & 0 deletions draftlogs/7199_fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Do not convert url-sourced layout images to data uri unless we're in staticPlot mode, to improve interactivity when images are changed with zoom/pan [[#7199](https://github.com/plotly/plotly.js/pull/7199)]
1 change: 1 addition & 0 deletions draftlogs/7204_fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fix mablibre source map [[#7204](https://github.com/plotly/plotly.js/pull/7204)]
1 change: 1 addition & 0 deletions draftlogs/7205_fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fix years in license [[#7205](https://github.com/plotly/plotly.js/pull/7205)]
2 changes: 1 addition & 1 deletion src/components/images/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ module.exports = function draw(gd) {

thisImage.attr('xmlns', xmlnsNamespaces.svg);

if(d.source && d.source.slice(0, 5) === 'data:') {
if(!gd._context.staticPlot || (d.source && d.source.slice(0, 5) === 'data:')) {
thisImage.attr('xlink:href', d.source);
this._imgSrc = d.source;
} else {
Expand Down
1 change: 1 addition & 0 deletions src/components/selections/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
for(var q = 0; q < selections.length; q++) {
var s = fullLayout.selections[q];
if(
!s ||
s.xref !== xRef ||
s.yref !== yRef
) {
Expand Down
18 changes: 13 additions & 5 deletions src/plots/cartesian/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,10 @@ function makeSubplotLayer(gd, plotinfo) {
var yLayer = constants.layerValue2layerClass[plotinfo.yaxis.layer];
var hasOnlyLargeSploms = fullLayout._hasOnlyLargeSploms;

if(!plotinfo.mainplot || fullLayout._zindices.length > 1) {
var hasMultipleZ = fullLayout._zindices.length > 1;
var mainplotinfo = plotinfo.mainplotinfo;

if(!plotinfo.mainplot || hasMultipleZ) {
if(hasOnlyLargeSploms) {
// TODO could do even better
// - we don't need plot (but we would have to mock it in lsInner
Expand All @@ -585,9 +588,15 @@ function makeSubplotLayer(gd, plotinfo) {
plotinfo.shapelayer = ensureSingle(backLayer, 'g', 'shapelayer');
plotinfo.imagelayer = ensureSingle(backLayer, 'g', 'imagelayer');

plotinfo.minorGridlayer = ensureSingle(plotgroup, 'g', 'minor-gridlayer');
plotinfo.gridlayer = ensureSingle(plotgroup, 'g', 'gridlayer');
plotinfo.zerolinelayer = ensureSingle(plotgroup, 'g', 'zerolinelayer');
if(mainplotinfo && hasMultipleZ) {
plotinfo.minorGridlayer = mainplotinfo.minorGridlayer;
plotinfo.gridlayer = mainplotinfo.gridlayer;
plotinfo.zerolinelayer = mainplotinfo.zerolinelayer;
} else {
plotinfo.minorGridlayer = ensureSingle(plotgroup, 'g', 'minor-gridlayer');
plotinfo.gridlayer = ensureSingle(plotgroup, 'g', 'gridlayer');
plotinfo.zerolinelayer = ensureSingle(plotgroup, 'g', 'zerolinelayer');
}

var betweenLayer = ensureSingle(plotgroup, 'g', 'layer-between');
plotinfo.shapelayerBetween = ensureSingle(betweenLayer, 'g', 'shapelayer');
Expand Down Expand Up @@ -622,7 +631,6 @@ function makeSubplotLayer(gd, plotinfo) {
}
}
} else {
var mainplotinfo = plotinfo.mainplotinfo;
var mainplotgroup = mainplotinfo.plotgroup;
var xId = id + '-x';
var yId = id + '-y';
Expand Down
2 changes: 1 addition & 1 deletion src/plots/map/map.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

var maplibregl = require('maplibre-gl/dist/maplibre-gl-unminified');
var maplibregl = require('maplibre-gl');

var Lib = require('../../lib');
var geoUtils = require('../../lib/geo_location_utils');
Expand Down
4 changes: 4 additions & 0 deletions src/traces/scatterternary/calc.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = function calc(gd, trace) {
var displaySum = ternary.sum;
var normSum = trace.sum || displaySum;
var arrays = {a: trace.a, b: trace.b, c: trace.c};
var ids = trace.ids;

var i, j, dataArray, newArray, fillArray1, fillArray2;

Expand Down Expand Up @@ -58,6 +59,9 @@ module.exports = function calc(gd, trace) {
y = a;
x = c - b;
cd[i] = {x: x, y: y, a: a, b: b, c: c};
if (ids) {
cd[i].id = ids[i];
}
} else cd[i] = {x: false, y: false};
}

Expand Down
Binary file modified test/image/baselines/map_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/map_angles.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/map_bubbles-text.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/map_bubbles.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/map_carto-style.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/map_carto-text.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/map_choropleth-multiple.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/map_choropleth-raw-geojson.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/map_choropleth0-legend.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/map_choropleth0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/map_connectgaps.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/map_density-multiple.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/map_density-multiple_legend.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/map_density0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/map_fill.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/map_fonts-supported-metropolis-italic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/map_fonts-supported-metropolis-weight.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/map_fonts-supported-metropolis.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/map_fonts-supported-open-sans-weight.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/map_fonts-supported-open-sans.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/map_geojson-attributes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/map_layers.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/map_scattercluster.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/map_symbol-text.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/map_texttemplate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/mapbox_angles.png
Binary file modified test/image/baselines/mapbox_carto-style.png
Binary file modified test/image/baselines/mapbox_carto-text.png
Binary file modified test/image/baselines/mapbox_fonts-supported-metropolis.png
Binary file modified test/image/baselines/mapbox_geojson-attributes.png
Binary file modified test/image/baselines/mapbox_layers.png
Binary file modified test/image/baselines/mapbox_predefined-styles1.png
Binary file modified test/image/baselines/mapbox_predefined-styles2.png
Binary file modified test/image/baselines/mapbox_symbol-text.png
Binary file modified test/image/baselines/mapbox_texttemplate.png
1 change: 1 addition & 0 deletions test/image/mocks/ternary_simple.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"a": [2, 1, 1],
"b": [1, 2, 1],
"c": [1, 1, 2.12345],
"ids": ["first ID", "second ID", "third ID"],
"type": "scatterternary"
}
],
Expand Down
42 changes: 35 additions & 7 deletions test/jasmine/tests/layout_images_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,8 @@ describe('Layout images', function() {
var gd;
var data = [{ x: [1, 2, 3], y: [1, 2, 3] }];

beforeEach(function(done) {
gd = createGraphDiv();
Plotly.newPlot(gd, data, {
var layoutFn = function() {
return {
images: [{
source: jsLogo,
x: 2,
Expand All @@ -331,12 +330,17 @@ describe('Layout images', function() {
}],
width: 500,
height: 400
}).then(done);
};
}

beforeEach(function(done) {
gd = createGraphDiv();
Plotly.newPlot(gd, data, layoutFn()).then(done);
});

afterEach(destroyGraphDiv);

it('should only create canvas if url image', function(done) {
it('should only create canvas if url image and staticPlot', function(done) {
var originalCreateElement = document.createElement;
var newCanvasElement;
spyOn(document, 'createElement').and.callFake(function(elementType) {
Expand All @@ -350,7 +354,21 @@ describe('Layout images', function() {

Plotly.relayout(gd, 'images[0].source', dataUriImage)
.then(function() {
expect(newCanvasElement).toBeUndefined();
expect(newCanvasElement).withContext('non-static data uri').toBeUndefined();

return Plotly.relayout(gd, 'images[0].source', jsLogo);
})
.then(function() {
expect(newCanvasElement).withContext('non-static url').toBeUndefined();

return Plotly.newPlot(gd, data, layoutFn(), {staticPlot: true});
})
.then(function() {
newCanvasElement = undefined;
return Plotly.relayout(gd, 'images[0].source', dataUriImage);
})
.then(function() {
expect(newCanvasElement).withContext('static data uri').toBeUndefined();

return Plotly.relayout(gd, 'images[0].source', jsLogo);
})
Expand Down Expand Up @@ -392,11 +410,21 @@ describe('Layout images', function() {
.then(done, done.fail);
});

it('should remove the image tag if an invalid source', function(done) {
it('should remove the image tag if an invalid source and staticPlot', function(done) {
var selection = d3Select('image');
expect(selection.size()).toBe(1);

Plotly.relayout(gd, 'images[0].source', 'invalidUrl')
.then(function() {
var newSelection = d3Select('image');
expect(newSelection.size()).toBe(1);
})
.then(function() {
return Plotly.newPlot(gd, data, layoutFn(), {staticPlot: true});
})
.then(function() {
return Plotly.relayout(gd, 'images[0].source', 'invalidUrl');
})
.then(function() {
var newSelection = d3Select('image');
expect(newSelection.size()).toBe(0);
Expand Down
103 changes: 102 additions & 1 deletion test/jasmine/tests/select_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function assertSelectionNodes(cornerCnt, outlineCnt, _msg) {
}

var selectingCnt, selectingData, selectedCnt, selectedData, deselectCnt, doubleClickData;
var selectedPromise, deselectPromise, clickedPromise;
var selectedPromise, deselectPromise, clickedPromise, relayoutPromise;

function resetEvents(gd) {
selectingCnt = 0;
Expand Down Expand Up @@ -125,6 +125,12 @@ function resetEvents(gd) {
resolve();
});
});

relayoutPromise = new Promise(function(resolve) {
gd.on('plotly_relayout', function() {
resolve();
});
});
}

function assertEventCounts(selecting, selected, deselect, msg) {
Expand Down Expand Up @@ -1035,6 +1041,100 @@ describe('Test select box and lasso in general:', function() {
});
});

describe('select / deselect with fake selections', function() {
var gd;
beforeEach(function(done) {
gd = createGraphDiv();

var mockCopy = Lib.extendDeep({}, mock);
mockCopy.layout.dragmode = 'select';
mockCopy.layout.hovermode = 'closest';
mockCopy.layout.selections = [null];
addInvisible(mockCopy);

_newPlot(gd, mockCopy.data, mockCopy.layout)
.then(done);
});

it('should trigger selecting/selected/deselect events', function(done) {
resetEvents(gd);

drag(selectPath);

selectedPromise.then(function() {
expect(selectedCnt).toBe(1, 'with the correct selected count');
assertEventData(selectedData.points, [{
curveNumber: 0,
pointNumber: 0,
pointIndex: 0,
x: 0.002,
y: 16.25
}, {
curveNumber: 0,
pointNumber: 1,
pointIndex: 1,
x: 0.004,
y: 12.5
}], 'with the correct selected points (2)');
assertRange(selectedData.range, {
x: [0.002000, 0.0046236],
y: [0.10209191961595454, 24.512223978291406]
}, 'with the correct selected range');

return doubleClick(250, 200);
})
.then(deselectPromise)
.then(function() {
expect(doubleClickData).toBe(null, 'with the correct deselect data');
})
.then(done, done.fail);
});

it('should handle add/sub selection', function(done) {
resetEvents(gd);
expect(gd.layout.selections.length).toBe(1);

drag([[193, 193], [213, 193]], {shiftKey: true})

selectedPromise.then(function() {
expect(selectedCnt).toBe(1, 'with the correct selected count');
assertEventData(selectedData.points, [{
curveNumber: 0,
pointNumber: 4,
pointIndex: 4,
x: 0.013,
y: 6.875
}], 'with the correct selected points (1)');
})
.then(function() {
// this is not working here, but it works in the test dashboard, not sure why
// but at least this test shows us that no errors are thrown.
// expect(gd.layout.selections.length).toBe(2, 'fake selection is still there');

resetEvents(gd);

return doubleClick(250, 200);
})
.then(relayoutPromise)
.then(function() {
expect(gd.layout.selections.length).toBe(0, 'fake selection is cleared');
expect(doubleClickData).toBe(null, 'with the correct deselect data');
})
.then(done, done.fail);
});

it('should clear fake selections on doubleclick', function(done) {
resetEvents(gd);

doubleClick(250, 200);

relayoutPromise.then(function() {
expect(gd.layout.selections.length).toBe(0, 'fake selections are cleared');
})
.then(done, done.fail);
});
});

describe('lasso events', function() {
var mockCopy = Lib.extendDeep({}, mock);
mockCopy.layout.dragmode = 'lasso';
Expand Down Expand Up @@ -1979,6 +2079,7 @@ describe('Test select box and lasso per trace:', function() {
function() {
assertPoints([[0.5, 0.25, 0.25]]);
assertSelectedPoints({0: [0]});
expect(selectedData.points[0].id).toBe("first ID")
},
[380, 180],
BOXEVENTS, 'scatterternary select'
Expand Down
2 changes: 1 addition & 1 deletion test/jasmine/tests/ternary_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var assertHoverLabelContent = customAssertions.assertHoverLabelContent;

var SORTED_EVENT_KEYS = [
'data', 'fullData', 'curveNumber', 'pointNumber', 'pointIndex',
'xaxis', 'yaxis', 'a', 'b', 'c',
'xaxis', 'yaxis', 'a', 'b', 'c', 'id',
'bbox'
].sort();

Expand Down