我试图将时间序列金融OHLC数据绘制为R使用Highstock JS的烛台 . 我正在使用rcharts包 . 然而,该情节需要大量的时间来显示(10,000烛光约5分钟) .

我也尝试使用ggplot2构建蜡烛和交互性,使用了plotly . 虽然ggplot2可以非常快速地渲染绘图,但是当我使用plotly时,它会减慢速度 .

我在图表中基本上需要工具提示和水平滚动条 .

我添加了一个使用ggplot2创建的示例代码和使用scroll滚动的示例代码

ui.R

library(shiny)

shinyUI(fluidPage(

  # Application title
  titlePanel(NULL),

  # Sidebar with a slider input for scrolling
  sidebarLayout(
    sidebarPanel(
      sliderInput("integer", "Scroll parameter:", 
                  min=51, max=2000, value=100)
    ),

    mainPanel(
      plotOutput("plot",
                 hover = hoverOpts(
                   id = "plot_hover")
      )
    )),


    fluidRow(
      column(width = 3,
             verbatimTextOutput("hover_info")
      )

)))

server.R

library(ggplot2)
library(shiny)
library(plotly)

shinyServer(function(input, output) {

  set.seed(1)
  s <- sample(seq(from = 1, to = 50, by = 1), size = 2000, replace = TRUE)
  data <- data.frame(x = 1:length(s), y = s)

  df <- reactive({

    df <- data[(input$integer - 50):input$integer,] # selecting only 50 rows of data frame and generating the plot
    return(df)
  })


  output$plot <- renderPlot({


    temp <- df()
    p <- ggplot(data = temp, mapping = aes(x=x,y=y))
    p <- p+geom_line()
    print(p)
   # g <- ggplotly(p) # for conversion to plotly
   # print(g)

  })

  output$hover_info <- renderPrint({
    cat("input$plot_hover:\n")
    str(input$plot_hover)
  })
})

这个问题是,每次我更改滚动参数时,都会重新创建绘图,因此处理时间很慢(大约.3秒) . 当我用鼠标移动时,滚动也不平滑 .

有什么方法可以加载整个ggplot在高分辨率和滚动条 .

此外,我需要一个工具提示,这就是为什么我不能加载为图像我猜 .

我知道,对于交互性,所需的处理时间很长 . 但是有没有其他方法可以用来渲染更快的图表 .

我在带有8 GB RAM的MAC OS上运行 .