From 3de3d83739d28e9ce097e3e821435039a8cc2e48 Mon Sep 17 00:00:00 2001 From: Jamal Date: Tue, 29 Sep 2026 01:14:01 +0200 Subject: [PATCH 1/2] fix: Fill histogram2dcontour levels below zero histogram2dcontour does not coerce `contours.type`, so closeBoundaries matched neither switch case and left `prefixBoundary` unset. The empty bin ring around a histogram2dcontour reads as 0 at the edge, so every level below 0 needs the perimeter prefix. Without it, those fills covered only the region below the level, and the region between the level and the edge took the background color. Treat an unset `contours.type` as `levels`, the attribute default. Fixes #8005 --- draftlogs/XXXX_fix.md | 1 + src/traces/contour/close_boundaries.js | 3 ++- test/jasmine/tests/contour_test.js | 19 +++++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 draftlogs/XXXX_fix.md diff --git a/draftlogs/XXXX_fix.md b/draftlogs/XXXX_fix.md new file mode 100644 index 00000000000..b128ce894c6 --- /dev/null +++ b/draftlogs/XXXX_fix.md @@ -0,0 +1 @@ + - Fix `histogram2dcontour` fill colors when bin values are negative [[#XXXX](https://github.com/plotly/plotly.js/pull/XXXX)] diff --git a/src/traces/contour/close_boundaries.js b/src/traces/contour/close_boundaries.js index 8435d5f40b4..92338d0e50c 100644 --- a/src/traces/contour/close_boundaries.js +++ b/src/traces/contour/close_boundaries.js @@ -5,7 +5,8 @@ module.exports = function(pathinfo, contours) { var z = pi0.z; var i; - switch(contours.type) { + // histogram2dcontour does not coerce `contours.type` + switch(contours.type || 'levels') { case 'levels': // Why (just) use z[0][0] and z[0][1]? // diff --git a/test/jasmine/tests/contour_test.js b/test/jasmine/tests/contour_test.js index ae098a30702..710eebec5fc 100644 --- a/test/jasmine/tests/contour_test.js +++ b/test/jasmine/tests/contour_test.js @@ -650,6 +650,25 @@ describe('contour plotting and editing', function() { }) .then(done, done.fail); }); + + it('fills histogram2dcontour levels above negative bin values', (done) => { + Plotly.newPlot(gd, [{ + type: 'histogram2dcontour', + x: [1, 2, 3, 4, 1, 2, 3, 4], + y: [1, 1, 1, 1, 2, 2, 2, 2], + z: [-10, -50, -100, -150, -10, -50, -100, -150], + histfunc: 'avg', + contours: {coloring: 'fill'} + }]) + .then(() => { + const fills = d3SelectAll('.contourfill path'); + expect(fills.size()).toBe(13); + fills.each((d) => { + expect(d.prefixBoundary).toBe(true, `level ${d.level}`); + }); + }) + .then(done, done.fail); + }); }); describe('contour hover', function() { From d24fd4b43fd90543c72d2cfbf9d56271bc1a1b45 Mon Sep 17 00:00:00 2001 From: Jamal Date: Tue, 29 Sep 2026 01:24:25 +0200 Subject: [PATCH 2/2] chore: Rename draftlog to 8088_fix.md --- draftlogs/{XXXX_fix.md => 8088_fix.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename draftlogs/{XXXX_fix.md => 8088_fix.md} (50%) diff --git a/draftlogs/XXXX_fix.md b/draftlogs/8088_fix.md similarity index 50% rename from draftlogs/XXXX_fix.md rename to draftlogs/8088_fix.md index b128ce894c6..344b2b2a08e 100644 --- a/draftlogs/XXXX_fix.md +++ b/draftlogs/8088_fix.md @@ -1 +1 @@ - - Fix `histogram2dcontour` fill colors when bin values are negative [[#XXXX](https://github.com/plotly/plotly.js/pull/XXXX)] + - Fix `histogram2dcontour` fill colors when bin values are negative [[#8088](https://github.com/plotly/plotly.js/pull/8088)]