我试图在闪亮的应用程序中使用库闪亮和DT的数据表。
在Rstudio中本地运行时,一切正常,在服务器上运行时,我无法使用所有功能。让我举例说明一下:
server.R
var charts = Highcharts.chart('container', {
xAxis: {
type: 'datetime'
},
series: [{
type: 'area',
data: [
[Date.UTC(2015, 9, 25, 14, 13, 00), 3.500],
[Date.UTC(2015, 9, 25, 14, 13, 02), 3.501],
[Date.UTC(2015, 9, 25, 14, 13, 04), 3.502],
[Date.UTC(2015, 9, 25, 14, 13, 06), 3.505],
[Date.UTC(2015, 9, 25, 14, 13, 08), 3.509],
[Date.UTC(2015, 9, 25, 14, 13, 10), 3.507],
[Date.UTC(2015, 9, 25, 14, 13, 12), 3.510],
[Date.UTC(2015, 9, 25, 14, 13, 14), 3.525],
[Date.UTC(2015, 9, 25, 14, 13, 16), 3.536],
[Date.UTC(2015, 9, 25, 14, 13, 18), 3.575],
[Date.UTC(2015, 9, 25, 14, 13, 20), 3.595],
[Date.UTC(2015, 9, 25, 14, 13, 22), 3.514],
[Date.UTC(2015, 9, 25, 14, 13, 24), 3.525],
[Date.UTC(2015, 9, 25, 14, 13, 26), 3.536],
[Date.UTC(2015, 9, 25, 14, 13, 28), 3.514],
[Date.UTC(2015, 9, 25, 14, 13, 30), 3.510],
[Date.UTC(2015, 9, 25, 14, 13, 32), 3.523],
[Date.UTC(2015, 9, 25, 14, 13, 34), 3.596],
[Date.UTC(2015, 9, 26, 18, 13, 34), 4.596]
]
}]
});
和ui.R
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
和global.R正在加载闪亮的和DT库。
正在发生的事情是,table1被冻结并说&#34;正在处理......&#34;,表2没有更改页面,只有表3正常工作。
将服务器和ui更改为
时library(shiny)
library(DT)
require(rCharts)
# Define a server for the Shiny app
shinyServer(function(input, output,session) {
output$table1<-renderDataTable({
a<-data.table(seq(1,50),seq(1,50),rep("fsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdf",50))
} , options = list(orderClasses = TRUE,pageLength=10,lengthMenu = c(5, 10, 25,50),filter = "top"), escape = FALSE)
output$table2<-renderDataTable({
a<-as.data.table(data.table(seq(1,50),seq(1,50),rep("asfafasfafafaffsdfsdfsdfsdfsdf",50)))
}, options = list( processing=FALSE, columnDefs = list(list(
targets = 3,
render = JS(
"function(data, type, row, meta) {",
"return type === 'display' && data.length > 5 ?",
"'<span title=\"' + data + '\">' + data.substr(0, 5)+ '...</span>': data;",
"}")
)
),orderClasses = TRUE,pageLength=10,lengthMenu = c(5, 10, 25,50),filter = "top"), escape = FALSE)
output$table3<- shiny::renderDataTable({
a<-data.table(seq(1,50),seq(1,50),rep("fsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdf",50))
addCheckboxButtons <- paste0('<input type="checkbox" name="row_bb', a$V1, '" value="', a$V1, '">',"")
aa<-cbind(Pick=addCheckboxButtons, a)
return(aa)
} ,options = list(orderClasses = TRUE, lengthMenu = c(5, 25, 50), pageLength = 25)
, callback = JS("function(table) {
table.on('change.dt', 'tr td input:checkbox', function() {
setTimeout(function () {
Shiny.onInputChange('row_bb', $(this).add('tr td input:checkbox:checked').parent().siblings(':last-child').map(function() {
return $(this).text();
}).get())
}, 10);
});
}"),escape = FALSE
)
})
只有表2无法正常工作。
有人可以帮忙吗? 提前谢谢