Dynamic Axis Labels (Ticks) Misalignment with Data Points and Rangeslider
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- r
調査の方向性
plotly、lubridate、dplyr、tickvals、および x-axis rangeslider を使用した再現可能な R の例から始めます。固定された週次の tick 値が、ズームによる tick 調整とどのように相互作用するかを調査します。ズームによって過密を避けるために間隔が変更されても、月曜日を基準とする週次ラベルが正しいままであれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Description:
In my Plotly chart with a rangeslider, I'm facing a dilemma with axis labels (ticks). Without using tickvals, the chart incorrectly displays Sunday as the start of the week. When using tickvals to correct this, the axis labels don't dynamically adjust when zooming out, leading to overcrowding.
Expected Behavior:
- The x-axis should consistently display Monday as the start of each week.
- When zooming out, the axis should dynamically adjust to a coarser interval (e.g., every month, every quarter, or every year) to maintain readability.
- The rangeslider should allow smooth navigation while preserving appropriate tick density at different zoom levels.
Actual Behavior:
- Without
tickvals:
-
The chart incorrectly uses Sunday as the start of the week.
-
Zooming functions work as expected, with appropriate tick density at different zoom levels.
- With
tickvals:
-
The chart correctly displays Monday as the start of the week.
-
When zooming out, the axis doesn't adjust to a more appropriate interval, resulting in overcrowded and illegible labels.
Reproducible Example:
library(shiny)
library(plotly)
library(lubridate)
library(dplyr)
# Example data
data <- data.frame(
date = seq(as.Date("2024-01-01"), Sys.Date(), by = "day"),
value = runif(length(seq(as.Date("2024-01-01"), Sys.Date(), by = "day")), 10, 100)
)
# Aggregate data by week
data_weekly <- data %>%
mutate(week = floor_date(date, unit = "week", week_start = 1)) %>%
group_by(week) %>%
summarise(value = sum(value))
# Create a plot with the week start as the x-axis
fig <- plot_ly(data = data_weekly,
x = ~week,
y = ~value,
type = 'bar') %>%
layout(xaxis = list(
range = c(floor_date(max(data$date) - months(3) + days(4),
unit = "week", week_start = 1), # Set the x-axis range starting 3 months before the latest date
max(data$date + days(4))), # Extend the range to the maximum date (with 4 extra days for buffer)
tickvals = data_weekly$week # Use the start of each week as the ticks on the x-axis
)
)
fig %>%
config(displayModeBar = FALSE) %>%
layout(xaxis = list(rangeslider = list(visible = TRUE))) # Add a range slider for the x-axis
Additional Notes:
- The issue arises from the need to use
tickvalsto enforce Monday as the week start, which then prevents Plotly's automatic tick adjustment. - An ideal solution would combine correct week start representation (Monday) with dynamic tick adjustment when zooming.
System info
R version: 4.3.3 (2024-02-29)
Plotly version: 4.10.4
Operating System: Linux 5.15.173.1-1.cm2
- 主要言語
- R
- スター
- 2.7k
- フォーク
- 641
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
plotly/plotly.R のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
-
save_image Error オープン
難易度 3/5 1〜2日 初心者へのやさしさ 52/100
plotly/plotly.R の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
pharmaverse/rtables#1123 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
Trying to reassign a reactiveVal to the name of an existing reactiveVal doesn't overwrite the latter オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
RConsortium/rconsortium_website#649 · コメント 2 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
posit-dev/r-shinylive#203 ·