# NOT RUN {
# ------------------------------------------------------------------------------
# colour definition: apply a white to blue linear scale to the background of the
# first column ("col_0") over a range of values from 0 to 200
# ------------------------------------------------------------------------------
bgColScales <- list(
col_0 = JS('function colorScale(i){
var color = d3tf.scaleLinear()
.domain([0, 200])
.range(["white", "blue"]);
return color(i);
}'));
# ----------------------------------------------------------------------------
# simplified colour definition: first column, linear scale from white to green
# ----------------------------------------------------------------------------
bgColScales <- list(
col_0 = "auto:white:green"
)
# --------------------------------------------------------
# Minimal shiny app demonstrating the D3TableFilter widget
# server.R
# --------------------------------------------------------
library(shiny)
library(htmlwidgets)
library(D3TableFilter)
data(mtcars);
shinyServer(function(input, output, session) {
output$mtcars <- renderD3tf({
# Define table properties. See http://tablefilter.free.fr/doc.php
# for a complete reference
tableProps <- list(
btn_reset = TRUE,
# alphabetic sorting for the row names column, numeric for all other columns
col_types = c("string", rep("number", ncol(mtcars)))
);
d3tf(mtcars,
tableProps = tableProps,
extensions = list(
list(name = "sort")
),
showRowNames = TRUE,
tableStyle = "table table-bordered");
})
})
# }
Run the code above in your browser using DataLab