plotly / plotly/plotly.R

customdata array access issues

Đang mở
#2,219 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

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

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. 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

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.