From c104ed7a54dc254ea65e985c67b3e926a7fb449f Mon Sep 17 00:00:00 2001 From: D'Arcy Myronuk Date: Mon, 24 Apr 2023 21:53:05 -0400 Subject: [PATCH 1/3] fix: scatter3d marker opacity when marker.opacity is set to 0 --- src/traces/scatter3d/convert.js | 4 +++- test/jasmine/tests/scatter3d_test.js | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/traces/scatter3d/convert.js b/src/traces/scatter3d/convert.js index e186b1949f6..a0c760e9023 100644 --- a/src/traces/scatter3d/convert.js +++ b/src/traces/scatter3d/convert.js @@ -1,5 +1,7 @@ 'use strict'; +var isNumeric = require('fast-isnumeric'); + var createLinePlot = require('../../../stackgl_modules').gl_line3d; var createScatterPlot = require('../../../stackgl_modules').gl_scatter3d; var createErrorBars = require('../../../stackgl_modules').gl_error3d; @@ -403,7 +405,7 @@ proto.update = function(data) { // N.B. marker.opacity must be a scalar for performance var scatterOpacity = data.opacity; - if(data.marker && data.marker.opacity) scatterOpacity *= data.marker.opacity; + if(data.marker && isNumeric(data.marker.opacity)) scatterOpacity *= data.marker.opacity; scatterOptions = { gl: this.scene.glplot.gl, diff --git a/test/jasmine/tests/scatter3d_test.js b/test/jasmine/tests/scatter3d_test.js index bbe0a644550..ea6916ae435 100644 --- a/test/jasmine/tests/scatter3d_test.js +++ b/test/jasmine/tests/scatter3d_test.js @@ -329,4 +329,21 @@ describe('Test scatter3d interactions:', function() { }) .then(done, done.fail); }); + + it('@gl markers should be transparent when marker.opacity is 0', function(done) { + Plotly.newPlot(gd, [ + { + type: 'scatter3d', + x: [0], + y: [0], + z: [0], + mode: 'markers', + marker: { opacity: 0 } + }, + ]) + .then(function() { + expect(gd._fullLayout.scene._scene.glplot.objects[0].opacity).toEqual(0); + }) + .then(done, done.fail); + }); }); From 7b202b681c8479d9d90effc8457d8edae73e650c Mon Sep 17 00:00:00 2001 From: D'Arcy Myronuk Date: Tue, 25 Apr 2023 21:26:56 -0400 Subject: [PATCH 2/3] add draftlog and address pr feedback --- draftlogs/6581_fix.md | 1 + src/traces/scatter3d/convert.js | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) create mode 100644 draftlogs/6581_fix.md diff --git a/draftlogs/6581_fix.md b/draftlogs/6581_fix.md new file mode 100644 index 00000000000..87f2eb8a200 --- /dev/null +++ b/draftlogs/6581_fix.md @@ -0,0 +1 @@ + - fix scatter3d marker opacity when marker.opacity is set to 0 [[#6581](https://github.com/plotly/plotly.js/pull/6581)] \ No newline at end of file diff --git a/src/traces/scatter3d/convert.js b/src/traces/scatter3d/convert.js index a0c760e9023..bea698d1e68 100644 --- a/src/traces/scatter3d/convert.js +++ b/src/traces/scatter3d/convert.js @@ -1,7 +1,5 @@ 'use strict'; -var isNumeric = require('fast-isnumeric'); - var createLinePlot = require('../../../stackgl_modules').gl_line3d; var createScatterPlot = require('../../../stackgl_modules').gl_scatter3d; var createErrorBars = require('../../../stackgl_modules').gl_error3d; @@ -405,7 +403,7 @@ proto.update = function(data) { // N.B. marker.opacity must be a scalar for performance var scatterOpacity = data.opacity; - if(data.marker && isNumeric(data.marker.opacity)) scatterOpacity *= data.marker.opacity; + if(data.marker && data.marker.opacity !== undefined) scatterOpacity *= data.marker.opacity; scatterOptions = { gl: this.scene.glplot.gl, From 31f683b2fee43cd46054e3e74fec3384c5540b5d Mon Sep 17 00:00:00 2001 From: Mojtaba Samimi <33888540+archmoj@users.noreply.github.com> Date: Wed, 26 Apr 2023 15:21:06 -0400 Subject: [PATCH 3/3] Update draftlogs/6581_fix.md --- draftlogs/6581_fix.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/draftlogs/6581_fix.md b/draftlogs/6581_fix.md index 87f2eb8a200..16b9d199452 100644 --- a/draftlogs/6581_fix.md +++ b/draftlogs/6581_fix.md @@ -1 +1 @@ - - fix scatter3d marker opacity when marker.opacity is set to 0 [[#6581](https://github.com/plotly/plotly.js/pull/6581)] \ No newline at end of file + - fix scatter3d when `marker.opacity` is set to zero [[#6581](https://github.com/plotly/plotly.js/pull/6581)], with thanks to @dmyronuk for the contribution! \ No newline at end of file