From 786309b3fb7c3a02ba055fdcefa541e7d220f3e7 Mon Sep 17 00:00:00 2001 From: Ya-Fan Chen <20377719+Lexachoc@users.noreply.github.com> Date: Thu, 15 Oct 2026 17:49:01 +0200 Subject: [PATCH 1/3] Fix interval constraint value normalization in contour traces --- src/traces/contour/constraint_defaults.js | 6 ++-- test/jasmine/tests/contour_test.js | 39 +++++++++++++++++++++++ 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/src/traces/contour/constraint_defaults.js b/src/traces/contour/constraint_defaults.js index 2b0178d940f..280bef22dd6 100644 --- a/src/traces/contour/constraint_defaults.js +++ b/src/traces/contour/constraint_defaults.js @@ -57,10 +57,10 @@ function handleConstraintValueDefaults(coerce, contours) { contours.value = [zvalue, zvalue + 1]; } } else if(contours.value.length > 2) { - contours.value = contours.value.slice(2); - } else if(contours.length === 0) { + contours.value = contours.value.slice(0, 2); + } else if(contours.value.length === 0) { contours.value = [0, 1]; - } else if(contours.length < 2) { + } else if(contours.value.length < 2) { zvalue = parseFloat(contours.value[0]); contours.value = [zvalue, zvalue + 1]; } else { diff --git a/test/jasmine/tests/contour_test.js b/test/jasmine/tests/contour_test.js index ae098a30702..5a842fce097 100644 --- a/test/jasmine/tests/contour_test.js +++ b/test/jasmine/tests/contour_test.js @@ -115,6 +115,45 @@ describe('contour defaults', function() { expect(traceOut.xcalendar).toBe('coptic'); expect(traceOut.ycalendar).toBe('ethiopian'); }); + + it('should coerce constraint interval values to two numbers', function() { + var specs = [ + { + value: [], + expected: [0, 1] + }, + { + value: [5], + expected: [5, 6] + }, + { + value: [10, 20], + expected: [10, 20] + }, + { + value: [10, 20, 30], + expected: [10, 20] + } + ]; + + specs.forEach(function(spec) { + traceIn = { + type: 'contour', + z: [[0, 1], [2, 3]], + contours: { + type: 'constraint', + operation: '[]', + value: spec.value + } + }; + + traceOut = {}; + + supplyDefaults(traceIn, traceOut, defaultColor, layout); + + expect(traceOut.contours.value).toEqual(spec.expected); + }); + }); }); describe('contour makeColorMap', function() { From 13379ae63a1388309c48c6c2c793f1136b82ef50 Mon Sep 17 00:00:00 2001 From: Ya-Fan Chen <20377719+Lexachoc@users.noreply.github.com> Date: Thu, 15 Oct 2026 17:57:16 +0200 Subject: [PATCH 2/3] add draftlog --- draftlogs/8125.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 draftlogs/8125.md diff --git a/draftlogs/8125.md b/draftlogs/8125.md new file mode 100644 index 00000000000..19f43ac6ccf --- /dev/null +++ b/draftlogs/8125.md @@ -0,0 +1 @@ + - Fix normalization of `contours.value` for interval constraints in `contour` and `contourcarpet` [[#8125](https://github.com/plotly/plotly.js/pull/8125)] \ No newline at end of file From e26ff9c0d0797526e40e5daa085f12d04d5cdf7c Mon Sep 17 00:00:00 2001 From: Ya-Fan Chen <20377719+Lexachoc@users.noreply.github.com> Date: Thu, 15 Oct 2026 17:59:20 +0200 Subject: [PATCH 3/3] Rename draftlogs/8125.md to draftlogs/8125_fix.md --- draftlogs/{8125.md => 8125_fix.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename draftlogs/{8125.md => 8125_fix.md} (82%) diff --git a/draftlogs/8125.md b/draftlogs/8125_fix.md similarity index 82% rename from draftlogs/8125.md rename to draftlogs/8125_fix.md index 19f43ac6ccf..ed4aa06379b 100644 --- a/draftlogs/8125.md +++ b/draftlogs/8125_fix.md @@ -1 +1 @@ - - Fix normalization of `contours.value` for interval constraints in `contour` and `contourcarpet` [[#8125](https://github.com/plotly/plotly.js/pull/8125)] \ No newline at end of file + - Fix normalization of `contours.value` for interval constraints in `contour` and `contourcarpet` [[#8125](https://github.com/plotly/plotly.js/pull/8125)]