plotly / plotly/plotly.js

[BUG]: I cannot have reliable way of positioning title and legend on top without overlapping each other

Aperta
#7,556 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

bug
Lingua principale
JavaScript
Stelle
18.3k
Fork
2k
Merge medio
2g 12h
PR unite (30g)
28

Descrizione

Description

As plotly is responsive there's currently no way to place both legend and title on the top of the chart so that title and legend do not overlap (seems legend doesn't take into account title/subtitle). I know I have some tools which can help (like setting top margin/playing with y/maxheight/yref) but all of them aren't reliable as resizing the window (thus resizing the chart)/having long trace names/etc breaks all hardcoded configurations.

Steps to reproduce

Here's the demo: https://python-fiddle.com/examples/plotly?checkpoint=1757947390
Code behind it:

import plotly.express as px

df = px.data.gapminder().query("year==2007")
fig = px.scatter(df, x="gdpPercap", y="lifeExp", color="continent",
    size="pop", size_max=45, log_x=True)

fig.update_layout(legend=dict(
    orientation="h",
    entrywidth=70,
    yanchor="bottom",
    y=1.02,
    xanchor="center",
    x=1
))

fig.update_layout(title="Very long loong long long long title")

fig.show()
Notes

I'm posting python code here intentionally as I think this is the basic issue of the plotly.js rather than lack of configuration/bugs in Python wrapper.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia dalla riproduzione Python-Fiddle collegata e traccia il comportamento del layout responsive di plotly.js con un titolo lungo e una legenda orizzontale. Conferma il risultato ridimensionando il grafico e variando la lunghezza di trace-name; il lavoro è completato quando il titolo e la legenda non si sovrappongono senza spaziatura hardcoded, con un controllo di regressione che copra la riproduzione.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript
Ambito
data-visualization
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.