Set default button in rangeselector
まだ誰も着手していません。
- 主要言語
- R
- スター
- 2.7k
- フォーク
- 641
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
Stumbled across this topic on SO and wasn't entirely satisfied with the suggested workaround. Is this something that you might want to have a look at?
Here's a minimum reprex: say I wanted to plot daily ozone readings from the airquality dataset against time and add range selectors,
library(plotly)
dat = airquality
dat$Date = as.Date(paste(1973, dat$Month, dat$Day, sep = "-"))
p0 = plot_ly(dat, x = ~ Date, y = ~ Ozone, type = "bar")
p1 = p0 %>% layout(
xaxis = list(
rangeselector = list(
buttons = list(
list(
count = 1
, label = "1 mo"
, step = "month"
, stepmode = "backward"
)
, list(step = "all")
)
)
)
)
p1

, then the default zoom level would always be set to full range. If I wanted the default range to cover the last month only, I could certainly circumvent that through specifying a custom range as suggested in the linked answer,
p1 %>% layout(
xaxis = list(
range = c(
{
dt = max(dat$Date)
lubridate::month(dt) = lubridate::month(dt) - 1
dt
}
, max(dat$Date)
)
)
)

, which works nicely for point, line, etc. charts. Bar charts (not sure about other types), on the other hand, are being cut off at the first and last position. Now, I could also circumvent that by adding something like paste(dt, "10:00:00") and paste(max(dat$Date), "10:00:00") to my custom range, but I wonder whether this could be made a lot more user-friendly through enabling something like active = TRUE directly in the buttons definition?
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
plot_ly()、layout()、xaxis、rangeselector ボタンを使って airquality の reprex を再現し、その後、カスタム範囲の回避策と、要求されているデフォルトボタンの動作を比較します。rangeselector ボタンと xaxis の範囲がどのように処理されるかを追跡します。ボタンで初期範囲を指定でき、棒グラフが切り取られず、既存の例も引き続き動作すれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- r
- 領域
- data-visualization
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100