Performance 如何使plotly在Shining中更快
我想知道是否有什么好的方法来加快情节的表现,特别是他们的速度。目前,我正在尝试隔离绘图的数据,只留下两个输入,以反应性地更改绘图内容 我感到困惑的是,当我用固定数据测试那些Polly图时(我在shiny中隔离了),当更改这两个输入时,这些图运行得非常快。但是,当我使用isolate()和两个输入在SHINK中导入相同的逻辑时,POLT的运行速度非常慢 请帮忙 这是我目前的密码,谢谢Performance 如何使plotly在Shining中更快,performance,caching,input,shiny,plotly,Performance,Caching,Input,Shiny,Plotly,我想知道是否有什么好的方法来加快情节的表现,特别是他们的速度。目前,我正在尝试隔离绘图的数据,只留下两个输入,以反应性地更改绘图内容 我感到困惑的是,当我用固定数据测试那些Polly图时(我在shiny中隔离了),当更改这两个输入时,这些图运行得非常快。但是,当我使用isolate()和两个输入在SHINK中导入相同的逻辑时,POLT的运行速度非常慢 请帮忙 这是我目前的密码,谢谢 observe({ ##### Visualization - Daily Pattern ##### outpu
observe({
##### Visualization - Daily Pattern #####
output$TTPlotB<-renderPlotly({
#input$file_load
#data_daily<-
#data_daily2<<-data_daily
date1<-input$dateRange[1]
date2<-input$dateRange[2]
journey1<-input$journey[1]
journey2<-input$journey[2]
plot_ly(isolate({Alloc()})%>%
filter(date_range>= date1 & date_range<=date2 )%>%
filter(Days_in_journey %in% ( journey1:journey2 ))%>%
group_by(date_range,OEM,daily_available)%>%
summarise(ngm=min(daily_avail_ngm), ### use the min based on the selected journey
product=min(daily_avail_product), ### use the min based on the selected journey
lp=min(daily_avail_lp), ### use the min based on the selected journey
cart=min(daily_avail_cart), ### use the min based on the selected journey
email=min(daily_avail_email))%>%
gather(channel,channel_daily_avail,-c(date_range,OEM,daily_available))%>%
select(-c(daily_available))%>%
spread(OEM,channel_daily_avail)%>%
group_by(date_range,channel)%>%
mutate(Daily_tot=sum(HP,Dell,Lenovo,Acer,Asus,Others))%>%
mutate(D_HP_avai=round(100*HP/(input$OEM.HP.Aud.wk*1000/7),0))%>%
mutate(D_Dell_avai=round(100*Dell/(input$OEM.Dell.Aud.wk*1000/7),0))%>%
mutate(D_Leno_avai=round(100*Lenovo/(input$OEM.Lenovo.Aud.wk*1000/7),0))%>%
mutate(D_Acer_avai=round(100*Acer/(input$OEM.Acer.Aud.wk*1000/7),0))%>%
mutate(D_Asus_avai=round(100*Asus/(input$OEM.Asus.Aud.wk*1000/7),0))%>%
mutate(D_Oth_avai=round(100*Others/(input$OEM.Others.Aud.wk*1000/7),0))%>%as.data.table()
,
height = 500, width = 1450,
x=~date_range,
y=~Daily_tot,
type="scatter",
color=~channel,
mode="lines+markers",
hoverinfo = 'text',
text = ~paste('</br> <B> Channel:</B>', channel
,
'</br> <B> Total Available Machines:</B>', formatC(Daily_tot, format="d", big.mark=","),
'</br> <B> Selected Date:</B>',date_range,
'</br> <B> HP: </B>',formatC(HP, format="d", big.mark=","),',',round(100*HP/Daily_tot,0),'%',
' <B> HP Daily:</B>',D_HP_avai,'%' ,
'</br> <B> Dell: </B>',formatC(Dell, format="d", big.mark=","),',',round(100*Dell/Daily_tot,0),'%',
' <B> Dell Daily:</B>',D_Dell_avai ,'%',
'</br> <B> Lenovo: </B>',formatC(Lenovo, format="d", big.mark=","),',',round(100*Lenovo/Daily_tot,0),'%',
' <B> Lenovo Daily:</B>',D_Leno_avai ,'%',
'</br> <B> Acer: </B>',formatC(Acer, format="d", big.mark=","),',',round(100*Acer/Daily_tot,0),'%',
' <B> Acer Daily:</B>', D_Acer_avai,'%',
'</br> <B> Asus: </B>',formatC(Asus, format="d", big.mark=","),',',round(100*Asus/Daily_tot,0),'%',
' <B> Asus Daily:</B>',D_Asus_avai ,'%',
'</br> <B> Others: </B>',formatC(Others, format="d", big.mark=","),',',round(100*Others/Daily_tot,0),'%',
' <B> Other Daily:</B>',D_Oth_avai ,'%'
)
)%>%
layout(xaxis = list(title = 'Dates'),
yaxis = list(title = 'Available Machines')
)
})
观察({
#####可视化-每日模式#####
输出$TTB%
分组依据(日期范围,频道)%>%
突变(每日_tot=sum(惠普、戴尔、联想、宏碁、华硕等))%>%
变异(D_HP_avi=round(100*HP/(输入$OEM.HP.Aud.wk*1000/7),0))%>%
变异(D_Dell_avi=round(100*Dell/(输入$OEM.Dell.Aud.wk*1000/7),0))%>%
变异(D_Leno_avi=round(100*Lenovo/(输入$OEM.Lenovo.Aud.wk*1000/7),0))%>%
变异(D_Acer_avi=round(100*Acer/(输入$OEM.Acer.Aud.wk*1000/7),0))%>%
变异(D_Asus_avi=round(100*Asus/(输入$OEM.Asus.Aud.wk*1000/7),0))%>%
变异(D_Oth_avi=round(100*Others/(输入$OEM.Others.Aud.wk*1000/7),0))%>%as.data.table()
,
高度=500,宽度=1450,
x=~date\u范围,
y=~每日总收入,
type=“散布”,
颜色=~通道,
mode=“行+标记”,
hoverinfo='text',
text=~粘贴(“频道:”,频道
,
“可用机器总数:”,formatC(每日总计,format=“d”,big.mark=“,”,
“所选日期:”,日期范围,
“HP:”,formatC(HP,format=“d”,big.mark=“”,”,”,四舍五入(100*HP/每日总计,0),“%”,
“HP Daily:”,D_HP_Avi,%,
“Dell:”,formatC(戴尔,format=“d”,big.mark=“,”,”,四舍五入(100*Dell/每日总计,0),“%”,
“戴尔日报:”,D_Dell_avi,”,
“Lenovo:”,formatC(Lenovo,format=“d”,big.mark=“,”,”,”,四舍五入(100*Lenovo/Daily_tot,0),“%”,
“联想日报:”,D_Leno_Avi,”,
“宏碁:”,formatC(宏碁,format=“d”,big.mark=“,”,”,”,四舍五入(100*宏碁/每日总计,0),“%”,
‘宏碁日报:’,D_Acer_avi,%,
“Asus:”,formatC(Asus,format=“d”,big.mark=“”,”,”,四舍五入(100*Asus/每日总计,0),“%”,
《华硕日报》,《华硕日报》,%,
“其他:”,formatC(其他,format=“d”,big.mark=“,”,”,四舍五入(100*其他/每日总计,0),“%”,
“其他日报:”,D_Oth_avi,”
)
)%>%
布局(xaxis=列表(标题='日期'),
yaxis=列表(标题=‘可用机器’)
)
})
})