plotly / plotly/plotly.R

Sluggish performance when using add_annotations

Open
#1,747 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
2.7k
Forks
641
PR merge metrics
No merged PRs in 30d

Description

Adding "add_annotations" to many points on any plot, cause slow performance.
Please see the below minimal example

library(shiny)
library(plotly)
library(quantmod)

ui <- fluidPage(
  plotlyOutput("plot"),
  verbatimTextOutput("event")
)

server <- function(input, output) {

  output$plot <- renderPlotly({
    getSymbols("AAPL",src='yahoo')

    # basic example of ohlc charts
    df <- data.frame(Date=index(AAPL),coredata(AAPL))
    df <- tail(df, 500)
    p <- df %>%
      plot_ly(x = ~Date, type="candlestick",
              open = ~AAPL.Open, close = ~AAPL.Close,
              high = ~AAPL.High, low = ~AAPL.Low) %>%
      add_annotations(x = ~Date , y = ~AAPL.Open, text = "Tslow",xref = "x", yref = "y", yref = "y",ax = -30, ay = 40,
                      arrowcolor = 'rgb(0, 153, 51)', arrowsize = 2, arrowwidth = 1, arrowhead = 4)  %>%
      layout(title = "Basic Candlestick Chart",xaxis = list(rangeslider = list(visible = F)))
    p
  })

  output$event <- renderPrint({
    d <- event_data("plotly_hover")
    if (is.null(d)) "Hover on a point!" else d
  })
}

shinyApp(ui, server)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided R Shiny example with plotly, quantmod, and 500 candlestick points, then profile the add_annotations call. The issue names no source files or tests; done means identifying and addressing the cause of the sluggish annotation performance without breaking the example.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data-visualization, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.