2015-01-14 31 views
0

我試圖用rCharts包繪製數千個點,但是我發現它使用默認參數有點慢。我試圖設置turboThresold參數爲0,但它沒有幫助。在繪製數千個點時提高rCharts性能

這裏是性能的表格:

  • 繪製100分:00.05小號
  • 繪製1000點:00.54小號
  • 繪製10000點:17.00小號

任何人都可以提高此代碼的性能?

library(shiny) 
library(rCharts) 
runApp(
    # User interface with 1 select box, 1 graph and 1 timer 
    list(ui = pageWithSidebar( 
    headerPanel(""), 
    sidebarPanel( 
     selectInput("value",NULL,choices=c(100,1000,10000), selected = 100) 
    ), 
    mainPanel(  
     showOutput("plot", "highcharts"), 
     textOutput("timer") 
    ) 
), 
    # server side 
    server = function(input, output){ 
    values<-reactiveValues() 
    values$timer <- NULL 
    # generating highcharts plot 
    output$plot <- renderChart2({ 
     x <- 1:input$value 
     df <- data.frame(x, x^2) 
     names(df) <- c("x","xpower2") 
     values$timer <- Sys.time() 
     plot <- Highcharts$new() 
     plot$series(
     data = toJSONArray2(df, json = F, names = F), 
     name = "xpower2", 
     type = "line" 
    ) 
     plot$plotOptions(series=list(turboThreshold=0)) 
     return(plot) 
    }) 
    # calculating time 
    output$timer <- renderText({ 
     input$value 
     isolate({ 
     values$timer <- Sys.time() - values$timer 
     return(paste("Time elapsed :", round(values$timer,3) , "seconds")) 
     }) 
    }) 
    } 
) 
) 

感謝您的幫助, 馬特

+0

這些命令沒有幫助: 情節$ plotOptions(系列=名單(動畫= FALSE,enableMouseTracking = FALSE)) – mbh86

+0

嘗試O禁止陰影/動畫/標記 –

+0

嗨塞巴斯蒂安。不幸的是沒有改善 – mbh86

回答

0

一般來說,我會建議發送不超過約3000點,更與任何瀏覽器圖形包中的瀏覽器。這些選項是無窮無盡的,但依賴於數據。除此之外,我無法通過rCharts加速它,但是這裏是ggvis

library(shiny);library(ggvis) 
runApp(
    list(ui = fluidPage(
    titlePanel('ggvis speed example'), 
    sidebarLayout( 
    sidebarPanel( 
     selectInput('points','Points To Plot', 
        choices=c(100,1000,10000,100000), selected = 1000) 
    ), 
    mainPanel(  
     ggvisOutput('ggvis') 
    ) 
)), 
    server = function(input, output){ 
    reactive({ 
     1:input$points %>%    
     data.frame('x'=.,'y'=.^2) %>% 
     ggvis(~x, ~y) %>% 
     layer_points() %>% 
     add_axis("y", title_offset = 70) %>% 
     add_tooltip(function(df) HTML(paste0('x: ',df$x,'<br>y: ',df$y))) 
    }) %>% bind_shiny('ggvis') 
    } 
) 
) 
+0

由於某些原因,我不能使用「ggvis」包。我想我必須找到另一種展示我的系列的方式。我正在考慮將我的大型系列放入較小的系列中,選擇正確的方法以擁有相同的外觀。 – mbh86

+0

熱圖?我確信有一些更清晰的方法可以顯示出很多點,這取決於目的。 – ideamotor

+0

不是在我的情況下,我正在處理時間序列。 – mbh86