簡體   English   中英

在 Plotly R 中使用 map 中的 event_data 來渲染 dataTable

[英]Use event_data from map in Plotly R to render dataTable

我需要一些幫助,在 plotly r 中使用 event_data 來呈現數據表,而不僅僅是顯示 cwrevenumber 和 pointNumber。

    output$plot1 <- renderPlotly({
    df <- read.csv('https://raw.githubusercontent.com/plotly/datasets/master/2014_world_gdp_with_codes.csv')    

    # light grey boundaries
     l <- list(color = toRGB("grey"), width = 0.5)

    # specify map projection/options
    g <- list(
      showframe = FALSE,
      showcoastlines = FALSE,
      projection = list(type = 'Mercator')
      )

      plot_ly(df, z = GDP..BILLIONS., text = COUNTRY, locations = CODE, type =       'choropleth', source = 'click', color = GDP..BILLIONS., colors = 'Blues', marker =     list(line = l),
        colorbar = list(tickprefix = '$', title = 'GDP Billions US$')) %>%
  layout(title = '2014 Global GDP<br>Source:<a href="https://www.cia.gov/library/publications/the-world-factbook/fields/2195.html">CIA World Factbook</a>',
         geo = g)
    })


output$c_locate_info <- renderDataTable({
    event.data <- event_data(event='plotly_click', source = 'click') 

    if(is.null(event.data)==T) return('Select Regions for More Details')
    })    

我想你錯過了“其他”的論點

output$c_locate_info <- renderDataTable({
event.data <- event_data(event='plotly_click', source = 'click') 

if(is.null(event.data)==T) return('Select Regions for More Details') else d
})    

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM