JuliaPlots / JuliaPlots/PlotlyJS.jl

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

Open
#328 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
444
Forks
86
PR merge metrics
No merged PRs in 30d

Description

**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](https://github.com/sglyon/PlotlyJS.jl/blob/6580f9868ae8ada802eca8dc1327311b98436982/assets/index.js#L23-L35) 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
```js
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()`)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.