Horizontal Stacked Bar Labels Cut Off
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- JavaScript
- Estrellas
- 18.3k
- Forks
- 2k
- Merge medio
- 2 d 12 h
- PR fusionados (30 d)
- 28
Descripción
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!
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
No se especifica ningún archivo fuente, prueba ni punto de entrada. Empieza reproduciendo el ejemplo proporcionado de barras apiladas horizontales en plotly.js con el rango del eje x establecido en [0, 100], y luego rastrea cómo se renderizan las etiquetas cuando los totales de las barras superan ligeramente el rango. Se considerará terminado cuando se haya decidido el comportamiento previsto y se haya documentado o probado el manejo resultante.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- javascript
- Área
- data-visualization
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 35/100