[BUG]: I cannot have reliable way of positioning title and legend on top without overlapping each other
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- JavaScript
- Sterne
- 18.3k
- Forks
- 2k
- Ø Merge
- 2 T. 12 Std.
- Gemergte PRs (30 T.)
- 28
Beschreibung
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.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit der verknüpften Python-Fiddle-Reproduktion und verfolge das responsive Layout-Verhalten von plotly.js bei einem langen Titel und einer horizontalen Legende. Bestätige das Ergebnis, indem du den Chart in der Größe änderst und die Länge von trace-name variierst; die Aufgabe ist abgeschlossen, wenn sich Titel und Legende ohne hartcodierte Abstände nicht überlappen und eine Regressionsprüfung die Reproduktion abdeckt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript
- Bereich
- data-visualization
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 45/100