mirror of
https://github.com/rstudio/shiny.git
synced 2026-01-09 15:08:04 -05:00
Improve default table styles
This commit is contained in:
13
R/shiny.R
13
R/shiny.R
@@ -38,10 +38,15 @@ ShinyApp <- setRefClass(
|
||||
return(paste("data:image/png;base64,", b64, sep=''))
|
||||
})
|
||||
},
|
||||
define.table.output = function(name, func) {
|
||||
define.table.output = function(name, func, ...) {
|
||||
.outputs$set(name, function() {
|
||||
data <- func()
|
||||
return(paste(capture.output(print(xtable(data), type='html')), collapse="\n"))
|
||||
return(paste(
|
||||
capture.output(
|
||||
print(xtable(data, ...),
|
||||
type='html',
|
||||
html.table.attributes='class="data"')),
|
||||
collapse="\n"))
|
||||
})
|
||||
},
|
||||
instantiate.outputs = function() {
|
||||
@@ -147,8 +152,8 @@ start.app <- function(app, www.root, sys.www.root=NULL, port=8101L) {
|
||||
define.shiny.plot <- function(name, func, ...) {
|
||||
shinyapp$define.plot.output(name, func, ...)
|
||||
}
|
||||
define.shiny.table <- function(name, func) {
|
||||
shinyapp$define.table.output(name, func)
|
||||
define.shiny.table <- function(name, func, ...) {
|
||||
shinyapp$define.table.output(name, func, ...)
|
||||
}
|
||||
get.shiny.input <- function(name) {
|
||||
shinyapp$session$get(name)
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
<p>
|
||||
<label>Number of observations:</label><br />
|
||||
<input type="numeric" name="n" value="500" />
|
||||
<input type="number" name="n" value="500" min="1" max="10000" />
|
||||
</p>
|
||||
|
||||
<div id="plot1" class="live-plot"></div>
|
||||
|
||||
@@ -2,3 +2,14 @@ body.disconnected {
|
||||
background-color: #999;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
table.data {
|
||||
border-collapse: collapse;
|
||||
}
|
||||
table.data td, table th {
|
||||
border: 1px solid #CCC;
|
||||
padding: 3pt 8pt;
|
||||
}
|
||||
table.data td[align=right] {
|
||||
font-family: monospace;
|
||||
}
|
||||
Reference in New Issue
Block a user