Last active
May 12, 2016 18:41
-
-
Save aagarw30/eb4360b9630ae8bebe164c99e8632765 to your computer and use it in GitHub Desktop.
Multiple action buttons - example 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Title: Multiple Action Button Demo - Example # 2 | |
Description: An attempt to button event based navigation/actions. Powered by R, Shiny and Rstudio. | |
License: GPL-3 | |
Author: Abhinav Agrawal | |
DisplayMode: Showcase | |
Tags: action button, R, R Shiny | |
Type: Shiny |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
shinyServer(function(input, output,session){ | |
but1 = reactiveValues(but1=FALSE) | |
but2 = reactiveValues(but2=FALSE) | |
but3 = reactiveValues(but3=FALSE) | |
observeEvent(input$buttonuno, | |
isolate({but1$but1=TRUE | |
but2$but2=FALSE | |
but3$but3=FALSE | |
})) | |
observeEvent(input$buttondos, | |
isolate({but1$but1=FALSE | |
but2$but2=TRUE | |
but3$but3=FALSE | |
})) | |
observeEvent(input$buttontres, | |
isolate({but1$but1=FALSE | |
but2$but2=FALSE | |
but3$but3=TRUE | |
})) | |
observeEvent(input$buttoncuatro, | |
isolate({but1$but1=FALSE | |
but2$but2=FALSE | |
but3$but3=FALSE | |
})) | |
# output$uno <- renderText({ | |
# if(but1$but1) | |
# paste("ustedes selectado button uno") | |
# else | |
# return() | |
# }) | |
output$bubble <- renderGvis({ | |
if(but1$but1) | |
gvisBubbleChart(Fruits, idvar="Fruit", | |
xvar="Sales", yvar="Expenses", | |
colorvar="Year", sizevar="Profit", | |
options=list(title = "An example of Bubble Chart", | |
hAxis='{title: "Sales", minValue:75, maxValue:125}', | |
vAxis='{title: "Expenses"}' | |
) | |
) | |
else | |
return() | |
}) | |
output$scatter <- renderGvis({ | |
if(but2$but2) | |
gvisScatterChart(women, | |
options=list( | |
legend="none", | |
lineWidth=0, pointSize=1, | |
title="Example of Scatterplot using Women dataset", vAxis="{title:'weight (lbs)'}", | |
hAxis="{title:'height (in)'}", | |
width=300, height=300)) | |
else | |
return() | |
}) | |
output$guage <- renderGvis({ | |
if(but3$but3) | |
gvisGauge(CityPopularity, | |
options=list(title= 'Example of Guage', min=0, max=800, greenFrom=500, | |
greenTo=800, yellowFrom=300, yellowTo=500, | |
redFrom=0, redTo=300, width=400, height=300)) | |
else | |
return() | |
}) | |
# output$dos <- renderText({ | |
# if(but2$but2) | |
# paste("ustedes selectado button dos") | |
# else | |
# return() | |
# }) | |
# output$tres <- renderText({ | |
# if(but3$but3) | |
# paste("ustedes selectado button tres") | |
# else | |
# return() | |
# }) | |
# | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
library(googleVis) | |
shinyUI(fluidPage( | |
sidebarLayout( | |
sidebarPanel( | |
h5("use case - button based navigation"), | |
actionButton(inputId = "buttonuno", label = "Bubble Plot"), | |
br(), | |
br(), | |
actionButton(inputId = "buttondos", label = "Scatter Plot"), | |
br(), | |
br(), | |
actionButton(inputId = "buttontres", label = "Guage") | |
), | |
mainPanel( | |
htmlOutput("bubble"), | |
htmlOutput("scatter"), | |
htmlOutput("guage") | |
) | |
)) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment