timelyportfolio / shiny-websockets Goto Github PK
View Code? Open in Web Editor NEWexperiments with shiny at the core and with react
experiments with shiny at the core and with react
Hi Kent,
I was trying to create crosshairs on a ggplot2 and this is the best I could come up with. Do you think we can achieve this using native R functions or do we have to resort of Javascript. Given your expertise in this field, was wondering if you could provide your views.
library(shiny)
library(ggplot2)
library(Cairo) # For nicer ggplot2 output when deployed on Linux
# We'll use a subset of the mtcars data set, with fewer columns
# so that it prints nicely
mtcars2 <- mtcars[, c("mpg", "cyl", "disp", "hp", "wt", "am", "gear")]
ui <- fluidPage(
fluidRow(
column(width = 4,
plotOutput("plot1", height = 300,
# Equivalent to: click = clickOpts(id = "plot_click")
hover = hoverOpts(id = "plot_hover", delayType = "throttle"),
)
)
),
fluidRow(
column(width = 6,
h4("Hover Points"),
verbatimTextOutput("hover_info")
)
)
)
server <- function(input, output) {
output$plot1 <- renderPlot({
ggplot(mtcars2, aes(wt, mpg)) +
geom_point() +
geom_vline(xintercept = xdata(),colour="black", linetype = "longdash") +
geom_hline(yintercept = ydata(),colour="black", linetype = "longdash") +
scale_x_continuous(limit = c(0, 5)) +
scale_y_continuous(limit = c(0, 35))
})
xdata<-reactive({
ifelse(!is.null(input$plot_hover$x), return(input$plot_hover$x), return(0))
})
ydata<-reactive({
ifelse(!is.null(input$plot_hover$y), return(input$plot_hover$y), return(0))
})
output$hover_info <- renderPrint({
input$plot_hover$x
})
}
shinyApp(ui, server)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.