customdata array access issues
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- R
- Star
- 2.7k
- Fork
- 641
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
I am having issues accessing array elements inside of customdata using traditional JS indexing. The dot property accessor works, but using a key value or a numeric index inside of brackets doesn't seem to work. Here is my minimal reproducible example with only the version that works.
library(data.table)
library(plotly)
# Create sample data set of arbitrary length
n <- 1e3
dt <- data.table(
x=seq_len(n),
y=rnorm(n),
z=1e5*rnorm(n),
'text_label'=as.character(seq_len(n))
)
# Create customdata -- performance does not scale well with large n (1e6)
customCols <- c('z','text_label') # columns to include in customdata as they are not passed elsewhere
customdata <- split(dt[,.SD,.SDcols=customCols], seq_len(nrow(dt))) # fastest method of splitting data.frame
# Create and print plot
p <- plot_ly(data=dt) %>%
add_trace(
x=~x,
y=~y,
customdata=customdata,
hovertemplate='<b>Test Label: </b>%{customdata.text_label}',
type='scatter',
mode='markers'
)
print(p)
Hovertemplates that do not work
hovertemplate='<b>Test Label: </b>%{customdata[1]}',
hovertemplate='<b>Test Label: </b>%{customdata["text_label"]}',
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Tái hiện ví dụ R bằng plot_ly(), add_trace(), customdata và các biến thể hovertemplate được nêu trong issue. Bắt đầu bằng cách lần theo cách customdata được cung cấp cho các biểu thức hovertemplate, sau đó xác minh rằng truy cập bằng dấu ngoặc vuông theo số và theo khóa hoạt động cùng với truy cập bằng dấu chấm. Hoàn thành khi cả hai dạng hovertemplate bị lỗi đều hiển thị các giá trị customdata như mong đợi.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- javascript, r
- Lĩnh vực
- data-visualization
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100