2016-12-01 96 views
1

我想在閃亮的應用中呈現HTML情節。
我參考雷達圖表http://www.buildingwidgets.com/blog/2015/12/9/week-49-d3radarr如何在閃亮的應用程序中呈現HTML情節

但是這個情節並沒有渲染到閃亮的應用程序。

我提到這個問題 plotGoogleMaps in shiny app

但它是一種不同的。

有沒有辦法在有光澤的應用程序中渲染此圖?

我的代碼如下:

library(shiny) 
library(d3radarR) 
library(jsonlite) 

dataset = jsonlite::fromJSON(
' 
    [ 
    { 
     "key":"Nokia Smartphone", 
     "values":[ 
     { "axis":"Battery Life", "value":0.26 }, { "axis":"Brand", "value":0.10 }, 
     { "axis":"Contract Cost", "value":0.30 }, { "axis":"Design And Quality", "value":0.14 }, 
     { "axis":"Have Internet Connectivity", "value":0.22 }, { "axis":"Large Screen", "value":0.04 }, 
     { "axis":"Price Of Device", "value":0.41 }, { "axis":"To Be A Smartphone", "value":0.30 } 
     ] 
    }, 
    { 
     "key":"Samsung", 
     "values":[ 
     { "axis":"Battery Life", "value":0.27 }, { "axis":"Brand", "value":0.16 }, 
     { "axis":"Contract Cost", "value":0.35 }, { "axis":"Design And Quality", "value":0.13 }, 
     { "axis":"Have Internet Connectivity", "value":0.20 }, { "axis":"Large Screen", "value":0.13 }, 
     { "axis":"Price Of Device", "value":0.35 }, { "axis":"To Be A Smartphone", "value":0.38 } 
     ] 
    }, 
    { 
     "key":"iPhone", 
     "values":[ 
     { "axis":"Battery Life", "value":0.22 }, { "axis":"Brand", "value":0.28 }, 
     { "axis":"Contract Cost", "value":0.29 }, { "axis":"Design And Quality", "value":0.17 }, 
     { "axis":"Have Internet Connectivity", "value":0.22 }, { "axis":"Large Screen", "value":0.02 }, 
     { "axis":"Price Of Device", "value":0.21 }, { "axis":"To Be A Smartphone", "value":0.50 } 
     ] 
    } 
    ] 
', 
    simplifyDataFrame = FALSE 
) 


ui <- pageWithSidebar(

    headerPanel("Rader Chart"), 

    sidebarPanel(

    selectInput('tmp1', 'Tmp1', c(None='.')), 
    selectInput('tmp2', 'Tmp2', c(None='.')) 

), 

    mainPanel(
    tabPanel("Plot", uiOutput('plot')) 
) 
) 

server <- function(input, output) { 

    output$plot <- renderUI({ 
    d3radar(json_data) 
    }) 
} 

shinyApp(ui=ui, server=server) 

回答

0

你需要使用特定的閃亮功能從d3radarR包:

dataset = jsonlite::fromJSON(
    ' 
    [ 
    { 
    "key":"Nokia Smartphone", 
    "values":[ 
    { "axis":"Battery Life", "value":0.26 }, { "axis":"Brand", "value":0.10 }, 
    { "axis":"Contract Cost", "value":0.30 }, { "axis":"Design And Quality", "value":0.14 }, 
    { "axis":"Have Internet Connectivity", "value":0.22 }, { "axis":"Large Screen", "value":0.04 }, 
    { "axis":"Price Of Device", "value":0.41 }, { "axis":"To Be A Smartphone", "value":0.30 } 
    ] 
    }, 
    { 
    "key":"Samsung", 
    "values":[ 
    { "axis":"Battery Life", "value":0.27 }, { "axis":"Brand", "value":0.16 }, 
    { "axis":"Contract Cost", "value":0.35 }, { "axis":"Design And Quality", "value":0.13 }, 
    { "axis":"Have Internet Connectivity", "value":0.20 }, { "axis":"Large Screen", "value":0.13 }, 
    { "axis":"Price Of Device", "value":0.35 }, { "axis":"To Be A Smartphone", "value":0.38 } 
    ] 
    }, 
    { 
    "key":"iPhone", 
    "values":[ 
    { "axis":"Battery Life", "value":0.22 }, { "axis":"Brand", "value":0.28 }, 
    { "axis":"Contract Cost", "value":0.29 }, { "axis":"Design And Quality", "value":0.17 }, 
    { "axis":"Have Internet Connectivity", "value":0.22 }, { "axis":"Large Screen", "value":0.02 }, 
    { "axis":"Price Of Device", "value":0.21 }, { "axis":"To Be A Smartphone", "value":0.50 } 
    ] 
    } 
    ] 
    ', 
    simplifyDataFrame = FALSE 
) 


ui <- pageWithSidebar(

    headerPanel("Rader Chart"), 

    sidebarPanel(

    selectInput('tmp1', 'Tmp1', c(None='.')), 
    selectInput('tmp2', 'Tmp2', c(None='.')) 

), 

    mainPanel(
    tabPanel("Plot", d3radarOutput('plot')) 
) 
) 

server <- function(input, output) { 

    output$plot <- renderD3radar({ 
    d3radar(dataset) 
    }) 
} 

shinyApp(ui=ui, server=server) 
+0

它的工作原理,謝謝。 – Rokmc1050

相關問題