plotly / plotly/plotly.js

Horizontal Stacked Bar Labels Cut Off

オープン
#6,651 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

bug P3
主要言語
JavaScript
スター
18.3k
フォーク
2k
平均マージ
2日 12時間
マージ済み PR(30日)
28

説明

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!

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

ソースファイル、テスト、エントリポイントのいずれも指定されていません。まず、x 軸の範囲を [0, 100] に設定して、提供された plotly.js の水平積み上げ棒グラフの例を再現し、次に棒の合計が範囲をわずかに超えたときにラベルがどのようにレンダリングされるかを追跡してください。想定される動作を決定し、その結果生じる処理を文書化またはテストすれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript
領域
data-visualization
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。