plotly / plotly/plotly.py

On_selection event in faceted plot only works correctly in first facet

Aberta
#4,423 0 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

bug P3
Linguagem predominante
Python
Estrelas
18.8k
Forks
2.8k
Merge médio
16h 26min
PRs com merge (30d)
21

Descrição

Hello,
I’m trying to catch on_selection events in a faceted figure.

I create a simple faceted figure, and attach an on_selection handler to all traces.
As an output, I simply print the customdata, and the selector.xrange.

When selecting an area in the first facet, the selector.xrange is an array of numbers, the customdata corresponds to the data for the left facet.
However, when I do the same in the second facet, the selector.xrange becomes an , and the customdata still appears to be coming from the left facet.

I expect the selector.xrange to also be an array of numbers, when selecting in the right facet.

Here are the sample code (to be executed in jupyter notebook) and a screenshot of the result.

py.init_notebook_mode()

df = pd.DataFrame({
    "x": [1,2,3,4,1,2,3,4],
    "y": [1,2,3,2,1,4,2,3],
    "side": ["left","left","left","left","right","right","right","right"],
    "customdata": [1,2,3,4,5,6,7,8]
})

fig = px.line(df, x="x", y="y", custom_data=["side","customdata"], facet_col="side")

# fig.update_layout(clickmode='event+select')
fig.update_layout(
            dragmode="select",
            clickmode="select"
        )
fig.update_traces(marker_size=20)

f = go.FigureWidget(fig)

def click_handler(trace, points, selector):
    print(trace.customdata)
    print(selector.xrange)
    
f.data[0].on_selection(click_handler)

f

image

Kind Regards

Bart

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Direção de pesquisa

Execute o exemplo de faceted-plot fornecido em um notebook Jupyter e inspecione o callback de seleção do FigureWidget anexado por meio de f.data[0].on_selection. Compare selector.xrange e trace.customdata ao selecionar as facetas esquerda e direita. Está concluído quando as seleções em ambas as facetas informarem o intervalo numérico e os dados da faceta apropriados.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
jupyter-notebook, python
Domínio
data-visualization
Tipo de issue
Bug
Dificuldade
3/5
Tempo estimado
1-2 dias
Status de atividade
Estagnada
Clareza
Razoavelmente clara
Facilidade para iniciantes
38/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.