2017-04-21 4 views
3

나는 윤이 나기에 새롭고 음모로 만든 원형 차트를 밀어 내려고했습니다. 단지 렌더링 된 HTML을 runapp 클릭하면 는 "Plotly"윤기가 플롯 플롯을 표시하지 않습니다.

코드는 내가있는 플롯을 참조 할

library(shiny) 
library(ggplot2) 
library(ggthemes) 
library(plotly) 
library(shiny) 
library(ggthemes) 
library(RODBC) 
library(magrittr) 

synddb <- odbcConnect("Syndromic", uid="uname", pwd="pwd", believeNRows=FALSE) 
totalcomplaints<-sqlQuery(channel=synddb,query= "select c.siteid,count(c.siteid) number_of_complaints, s.sitefullname from complainttmp c, site s 
          where s.siteid= c.siteid and c.siteid in(1,2,3,4,5,6,7,8, 10,11,19,20) 
          group by c.siteid,s.sitefullname 
          order by c.siteid asc") 


shinyServer <- function(input, output) { 
    output$plot2 <- renderPloty({ 
    print(
     plot_ly(totalcomplaints,labels=paste(totalcomplaints$sitefullname,totalcomplaints$siteid,sep = "-"),values = ~number_of_complaints, type = 'pie', 
       textposition = 'inside', 
       textinfo = 'label+percent+values', 
       insidetextfont = list(color = '#FFFFFF'), 
       hoverinfo = 'text', 
       text = ~paste(number_of_complaints, 'complaints'), 
       marker = list(colors = colors, 
          line = list(color = '#000000', width = 1)), 
       showlegend = T) %>% 
     layout(title = 'Complaints in Percentage', 
       xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE), 
       yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))) 
    }) 

} 

Server

library(shiny) 

shinyUI <- fluidPage( 
    titlePanel("Plotly"), 
    mainPanel(
    plotOutput("plot2"))) 

UI

에서 같다 즉 제목을 포함 일단 뷰어를 실행하면 뷰어가 렌더링되는 HTML 페이지에 나타나지 않습니다.

도움 주셔서 감사합니다.

+0

작품을하지만 한 번, 내가 renderplotly 사용 시도가 서버 –

답변

4

당신은 plotly를 사용하므로 renderPlotrenderPlotly로 변경되어, 로컬로 지금 을

output$plot2 <- renderPlotly({ 
+0

하이에서 분리를 말한다 발표하지만 여전히 표시되지 않습니다 차트 –

+1

'UI'에서'plotOutput' 대신'plotlyOutput' –

+0

감사합니다, 지금 로컬로 작동합니다, 한 번 공개되면 페이지가 회색으로 표시되어 서버에서 연결이 끊어졌습니다. –