Horizontal Stacked Bar Labels Cut Off
Personne n'a encore pris cette issue.
- Langage dominant
- JavaScript
- Étoiles
- 18.3k
- Forks
- 2k
- Merge moyen
- 2 j 12 h
- PR mergées (30 j)
- 28
Description
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!
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Aucun fichier source, test ou point d’entrée n’est indiqué. Commencez par reproduire l’exemple fourni de barres horizontales empilées dans plotly.js avec l’intervalle de l’axe x défini sur [0, 100], puis suivez le rendu des étiquettes lorsque les totaux des barres dépassent légèrement l’intervalle. La tâche sera considérée comme terminée une fois le comportement attendu déterminé et la gestion qui en résulte documentée ou testée.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- javascript
- Domaine
- data-visualization
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- À clarifier
- Accessibilité débutants
- 35/100