stacked bar chart does not display text when colour is supplied
未關閉
還沒有人認領這個 Issue。
- 主要語言
- R
- 星號
- 2.7k
- 分支
- 641
- PR 合併指標
- 30 天內沒有已合併 PR
描述
or vice versa - color attribute is ignored
I would like to have stacked bar chart with specific colours & labels for each value, but in current setting color is ignored or the text labels disappear:
library(data.table)
library(plotly)
x <- structure(
list(time = structure(c(19023, 19023, 19051, 19051), class = "Date"),
group = structure(c(2L, 1L, 2L, 1L), levels = c("FR", "DE"),
class = c("ordered", "factor")),
value = c(1.5, 0.7, 1.6, 0.8)), row.names = c(NA, -4L),
class = c("data.table", "data.frame"))
x
my_col <- c('red', 'blue')
plot_ly(x, x = ~time, y = ~value, type = 'bar'
, name = ~group
, colors = my_col # ignored
, text = ~ value, textposition = 'auto'
) %>% layout(barmode = 'stack')

# when adding color we lose text:
plot_ly(x, x = ~time, y = ~value, type = 'bar'
, name = ~group
, color = ~group
, colors = my_col
, text = ~ value, textposition = 'auto'
) %>% layout(barmode = 'stack')
# text isnt visiable
plot_ly(x, x = ~time, y = ~value, type = 'bar'
, color = ~group
, colors = my_col
, text = ~ value, textposition = 'auto'
) %>% layout(barmode = 'stack')
# text isnt visiable

貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
在 plotly.R 中重現 issue 中的堆疊長條圖範例,比較提供的色彩與文字標籤。先追蹤 R plotly API 如何處理堆疊長條圖的色彩與文字;完成的標準是要求的色彩和值標籤都能同時保持可見。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- r
- 領域
- data-visualization
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100