PlotlyJS.jl icon indicating copy to clipboard operation
PlotlyJS.jl copied to clipboard

Problem getting "customdata" field from 3d plots from plotly_events

Open disberd opened this issue 4 years ago • 0 comments

Describe the bug When trying to access the "customdata" field during plotly events, no data is returned to Julia even though such data exists in the original plot data.

I tried debugging the problem with my limited Julia and Javascript knowledge and the problem is probably due to the fact that this javascript code to filter data before passing it to Julia tries to index "customdata" as a 1D array.

I also put the portion of the code here for readibility

            const fullPoint = eventData.points[i];
            const pointData = filter(function(o) {
                return !contains(type(o), ['Object', 'Array'])
            }, fullPoint);
            if (has('curveNumber', fullPoint) &&
                has('pointNumber', fullPoint) &&
                has('customdata', data[pointData.curveNumber])
            ) {
                pointData['customdata'] = data[
                    pointData.curveNumber
                ].customdata[fullPoint.pointNumber];
            }

In the case of plots having x, y and z fields like the contour plot I was trying, pointNumber seems to be a 2-element array with x and y indices. Trying to access customdata[fullPoint.pointNumber] simply returns undefined even though actual data was present. In my trials, it also seems that the javascript fullPoint already has a correctly indexed "customdata" field, without the need of extracting it from the data object like in the lines above. Is there a specific reason for trying to extract it from data? I did try pulling the repo and commeting out the lines in the if clause above to see if that was enough to solve the problem but I keep getting node build errors that I still didn't manage to solve.

Version info

Please provide the following:

  1. output of julia command versioninfo() Julia Version 1.4.0 Commit b8e9a9ecc6 (2020-03-21 16:36 UTC) Platform Info: OS: Windows (x86_64-w64-mingw32) CPU: Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz WORD_SIZE: 64 LIBM: libopenlibm LLVM: libLLVM-8.0.1 (ORCJIT, skylake)

  2. Output running the following in Julia 0.7 or greater: using Pkg; pkg"status" (if you are on Julia 0.6 or earlier run Pkg.status())

disberd avatar May 18 '20 17:05 disberd