Skip to content

Plotly.update(...) to select points on a graph #5162

@LoganWlv

Description

@LoganWlv

Hi,

Use case :

I have a two axis graph and I want to update it with some selected points.
To do that I am using Plotly.update function and the selectedpoints property to pass the indexes of the points that I want to select.

Following the documentation :

image

It seems to expect a one dimensional array.
But with a one dimensional array it is not working and with a two dimensional array it works.

I did debug a bit the code and it seems that in the _restyle function (for instance in plotly_basic.js), we do some logic on the property value (to handle multi traces? )

for(i = 0; i < traces.length; i++) {
            cont = data[traces[i]];
            contFull = getFullTrace(traces[i]);
            var preGUI = fullLayout._tracePreGUI[contFull._fullInput.uid];
            param = makeNP(preGUI, guiEditFlag)(cont, ai);
            oldVal = param.get();

           //Here if my selectedpoints are '[1, 2, 3, 4, 5]', newVal will always be '[0]'
           // if selectedpoints are '[[1, 2, 3, 4, 5]]', newVal be identical
            newVal = Array.isArray(vi) ? vi[i % vi.length] : vi;

In my understanding selectedpoints should be defined as a
Two dimensional array containing integer indices of selected points for each trace.

Am I wrong?

Not working example

https://codepen.io/loganwlv/pen/jOqXQjN

Working example :

https://codepen.io/loganwlv/pen/ExKGObP

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions