plotly / plotly/plotly.js

[BUG]: I cannot have reliable way of positioning title and legend on top without overlapping each other

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

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

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

説明

Description

As plotly is responsive there's currently no way to place both legend and title on the top of the chart so that title and legend do not overlap (seems legend doesn't take into account title/subtitle). I know I have some tools which can help (like setting top margin/playing with y/maxheight/yref) but all of them aren't reliable as resizing the window (thus resizing the chart)/having long trace names/etc breaks all hardcoded configurations.

Steps to reproduce

Here's the demo: https://python-fiddle.com/examples/plotly?checkpoint=1757947390
Code behind it:

import plotly.express as px

df = px.data.gapminder().query("year==2007")
fig = px.scatter(df, x="gdpPercap", y="lifeExp", color="continent",
    size="pop", size_max=45, log_x=True)

fig.update_layout(legend=dict(
    orientation="h",
    entrywidth=70,
    yanchor="bottom",
    y=1.02,
    xanchor="center",
    x=1
))

fig.update_layout(title="Very long loong long long long title")

fig.show()
Notes

I'm posting python code here intentionally as I think this is the basic issue of the plotly.js rather than lack of configuration/bugs in Python wrapper.

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

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

はじめの一歩

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

調査の方向性

リンクされた Python-Fiddle の再現例から始め、長いタイトルと横向きの凡例に対する plotly.js の responsive レイアウト動作を追跡します。チャートのサイズを変更し、trace-name の長さを変えて結果を確認します。ハードコードされた間隔なしでタイトルと凡例が重ならず、再現例を対象とするリグレッションチェックがあれば完了です。

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

評価

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

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

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