Horizontal Stacked Bar Labels Cut Off
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
Hello! I've been encountering some behavior with labelling on stacked horizontal bar charts that I feel is somewhat strange.
Basically, when I try to add a label to each section of the stacked bar, everything works fine until I adjust the range of the x-axis to get rid of the grey space to the right of the bars. It looks like if the sum of any of the bars goes even slightly over the range of the x-axis, it causes some labels to not show up. What confuses me, and makes me unsure if this is intended or not, is that it appears as if the labels are correctly appearing in the JSON, but don't actually show up on the graph.
Here's an example:
import pandas as pd
import plotly.graph_objects as go
summary_figure = go.Figure()
summary_figure.add_trace(go.Bar(
name="Women",
text=["Women"]*4,
y = ["A","B","C","D"],
x = [50,60,70,85],
orientation = 'h',
textfont_color="white",
textangle=0,
textposition="inside",
insidetextanchor= "start",
cliponaxis=False,
))
summary_figure.add_trace(go.Bar(
name="Men",
text=["Men"]*4,
y = ["A","B","C","D"],
x = [50.001,40.001,30,15],
orientation = 'h',
textfont_color="white",
textangle=0,
textposition="inside",
insidetextanchor= "start",
cliponaxis=False,
))
summary_figure.update_layout(
barmode='stack',)
summary_figure.update_xaxes(range=[0, 100])
summary_figure.show()
In this example, "Men" appears in the JSON four times, but only gets displayed twice.
Because of tiny rounding discrepancies in our data, this behavior has led to a lot of confusion for my team. If it's intended, I'd love if there was some sort of warning to make it known that the bar is being truncated.
Thanks!
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
Keine Quelldatei, kein Test und kein Einstiegspunkt ist angegeben. Beginne damit, das bereitgestellte Beispiel für ein horizontales gestapeltes Balkendiagramm in plotly.js nachzubilden, wobei der Bereich der x-Achse auf [0, 100] gesetzt ist, und verfolge dann, wie Beschriftungen gerendert werden, wenn Balkensummen den Bereich geringfügig überschreiten. Als erledigt gilt, dass das beabsichtigte Verhalten festgelegt und die daraus resultierende Behandlung dokumentiert oder getestet wird.
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
- Muss geklärt werden
- Anfängerfreundlichkeit
- 35/100