Skip to content

Commit

Permalink
scatter dotSize param
Browse files Browse the repository at this point in the history
  • Loading branch information
kpatel427 committed Jul 23, 2019
1 parent cc255ca commit fbfabfd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
6 changes: 6 additions & 0 deletions 02_Body.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ library(ggplot2)
library(shinycssloaders)
library(shinyWidgets)


body <- dashboardBody(
includeCSS("template.css"),
shinyjs::useShinyjs(),
Expand Down Expand Up @@ -57,13 +58,15 @@ body <- dashboardBody(
)

),

div(class="output_box", style="width:150%;",
#tabBox(status="info","Plot Output", withSpinner(plotOutput('basic_barplot',height = '600px'),color = '#3c8dbc'),value = 'basic_barplot')
tabBox( height = '663px',title =
dropdownButton(
tags$h3("Set parameters"),
#selectInput(inputId = 'xcol', label = 'X Variable', choices = names(iris)),
selectInput(inputId = 'colorby', label = 'Color by', choices = c('None')),
#selectInput(inputId = 'selectTheme', label = 'Choose Theme', choices = c(theme_bw(), theme_classic()), selected = theme_bw()),
sliderInput(inputId = 'axisFont', label = 'Font Size', value = 10, min = 1, max = 50),
radioGroupButtons(
inputId = "legendPosition",
Expand All @@ -81,6 +84,9 @@ body <- dashboardBody(
conditionalPanel(condition = "input.radioPlot == 'Bar'",
selectInput(inputId = 'test1', label = 'Barplot specific Input', choices = c('None'))
),
conditionalPanel(condition = "input.radioPlot == 'Scatter'",
sliderInput(inputId = 'dotSize', label = 'Dot Size', value = 2, min = 1, max = 20)
),
#selectInput(inputId = 'ycol', label = 'Y Variable', choices = names(iris), selected = names(iris)[[2]]),
#sliderInput(inputId = 'clusters', label = 'Cluster count', value = 3, min = 1, max = 9),
circle = TRUE, status = "danger", icon = icon("gear"), width = "300px",
Expand Down
6 changes: 4 additions & 2 deletions app.R
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ shinyApp(
"Bar" = bar_plot(data = dt,x=input$selectX,y=input$selectY, colorby = input$colorby,
fontSize = input$axisFont, legendPos = input$legendPosition)$plot,
"Scatter" = scatter_plot(data = dt,x=input$selectX,y=input$selectY, colorby = input$colorby,
fontSize = input$axisFont, legendPos = input$legendPosition)$plot,
fontSize = input$axisFont, legendPos = input$legendPosition,
dotSize = input$dotSize)$plot,
"Line" = line_plot(data = dt,x=input$selectX,y=input$selectY, colorby = input$colorby,
fontSize = input$axisFont, legendPos = input$legendPosition)$plot
)
Expand All @@ -142,7 +143,8 @@ shinyApp(
"Bar" = bar_plot(data = dt,x=input$selectX,y=input$selectY, colorby = input$colorby,
fontSize = input$axisFont, legendPos = input$legendPosition)$code,
"Scatter" = scatter_plot(data = dt,x=input$selectX,y=input$selectY, colorby = input$colorby,
fontSize = input$axisFont, legendPos = input$legendPosition)$code,
fontSize = input$axisFont, legendPos = input$legendPosition,
dotSize = input$dotSize)$code,
"Line" = line_plot(data = dt,x=input$selectX,y=input$selectY, colorby = input$colorby,
fontSize = input$axisFont, legendPos = input$legendPosition)$code
)
Expand Down
10 changes: 5 additions & 5 deletions plots/01_Plots-Scatter.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@


#1.1 PLOTS CODE: Scatter Plot---------------------
scatter_plot <- function(data=dt,x=NULL,y=NULL, colorby, fontSize, legendPos) {
scatter_plot <- function(data=dt,x=NULL,y=NULL, colorby, fontSize, legendPos, dotSize) {
if(colorby == 'None'){
p <- ggplot(data, aes_string(x,y)) +
geom_point() +
geom_point(size = dotSize) +
theme(axis.text = element_text(size = fontSize),
axis.title.x = element_text(size = fontSize),
axis.title.y = element_text(size = fontSize))

code <- paste0('ggplot(data, aes(',x,',',y,')) +
geom_point() +
geom_point(size = ',dotSize,') +
theme(axis.text = element_text(size = ', fontSize,'),
axis.title.x = element_text(size = ', fontSize,'),
axis.title.y = element_text(size = ', fontSize,'))')
Expand All @@ -21,14 +21,14 @@ scatter_plot <- function(data=dt,x=NULL,y=NULL, colorby, fontSize, legendPos) {
return(ls)
} else{
p <- ggplot(data, aes_string(x,y, color = colorby)) +
geom_point() +
geom_point(size = dotSize) +
theme(axis.text = element_text(size = fontSize),
axis.title.x = element_text(size = fontSize),
axis.title.y = element_text(size = fontSize),
legend.position = legendPos)

code <- paste0('ggplot(data, aes(',x,',',y, ',' ,'color = ', colorby, ')) +
geom_point() +
geom_point(size = ',dotSize,') +
theme(axis.text = element_text(size = ', fontSize,'),
axis.title.x = element_text(size = ', fontSize,'),
axis.title.y = element_text(size = ', fontSize,'),
Expand Down

0 comments on commit fbfabfd

Please sign in to comment.