plotly / plotly/plotly.js

Horizontal Stacked Bar Labels Cut Off

Aperta
#6,651 5 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

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

Descrizione

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()

image

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!

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

Non è specificato alcun file sorgente, test o punto di ingresso. Inizia riproducendo l’esempio fornito di barre orizzontali impilate in plotly.js con l’intervallo dell’asse x impostato su [0, 100], quindi traccia il modo in cui vengono renderizzate le etichette quando i totali delle barre superano leggermente l’intervallo. Il lavoro sarà considerato completato quando sarà deciso il comportamento previsto e sarà documentata o testata la gestione risultante.

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
Da chiarire
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.