ggplotly dynamic ticks does not work with empty traces
Open
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 2.7k
- Forks
- 641
- PR merge metrics
- No merged PRs in 30d
Description
When using dynamicTicks for ggplotly in combination with dates, traces with empty data result in an error:
Error in as.POSIXct.default(x, origin = "1970-01-01", tz = scale$timezone) :
do not know how to convert 'x' to class "POSIXct"
This is because the invert_date function in gg2list() gets passed a NULL value (since no data exists for that specific layer).
p <- ggplot(mapping=aes(x=TIME, y=VAL)) +
geom_point(data=data.frame(TIME=as.POSIXct(character()), VAL=numeric())) +
geom_line(data=data.frame(TIME=c(Sys.time(), Sys.time()+lubridate::hours(2)), VAL=runif(2)))
plotly::ggplotly(p)
plotly::ggplotly(p, dynamicTicks=TRUE)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in gg2list(), focusing on the invert_date function mentioned in the report. Reproduce the supplied ggplotly example with an empty date trace and dynamicTicks=TRUE, then verify that the conversion no longer errors when a layer has no data.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100