Skip to content

Commit

Permalink
add size + fix shiny app
Browse files Browse the repository at this point in the history
  • Loading branch information
bthieurmel committed Apr 6, 2018
1 parent 4078a9b commit 3c33e2a
Show file tree
Hide file tree
Showing 5 changed files with 181 additions and 269 deletions.
9 changes: 4 additions & 5 deletions R/LinkAll.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ allDepFunction <- function(envir, name.functions) {

link <- toutfonc
functions.list <- unique(as.character(unlist(c(toutfonc))))

Visdata <- list()

Nomfun <- functions.list
Nomfun <- data.frame(cbind(id = 1:length(Nomfun), label = Nomfun))


func.link <- sort(unique(c(as.character(link[, 1]), as.character(link[, 2]))))
func.nom <- sort(unique(as.character(Nomfun[, 2])))

# func.link <- sort(unique(c(as.character(link[, 1]), as.character(link[, 2]))))
# func.nom <- sort(unique(as.character(Nomfun[, 2])))

if (!is.null(link)) {
fromto <- matrix(0, ncol = dim(link)[2], nrow = dim(link)[1])
Expand Down
21 changes: 17 additions & 4 deletions R/VisGraphAuto.R
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ prepareToVis <- function(link, functions.list = NULL) {
#' dep <- funDependencies('package:ibr','iterchoiceS1')
#' plot(dep)
#'
#' # size
#' plot(dep, height = "800px", width = "100%")
#'
#' @export
funDependencies <- function(envir, name.function) {
visdata <- prepareToVis(linksForOne(envir, name.function))
Expand All @@ -190,6 +193,9 @@ funDependencies <- function(envir, name.function) {
#' dep <- envirDependencies('package:ibr')
#' plot(dep)
#'
#' # size
#' plot(dep, height = "800px", width = "100%")
#'
#' @export
envirDependencies <- function(envir) {
name.functions <- allFunctionEnv(envir)
Expand Down Expand Up @@ -234,18 +240,25 @@ VisFunsmatrice <- function(Mat) {
#' Plot network for dependenciesGraphs object. Using visNetwork package.
#'
#' @param object : dependenciesGraphs object.
#' @param width : Width (optional, defaults to automatic sizing)
#' @param height : Height (optional, defaults to automatic sizing)
#'
#' @examples
#'
#' dep <- funDependencies('package:ibr','iterchoiceS1')
#' plot(dep)
#'
#' # size
#' plot(dep, height = "800px", width = "100%")
#'
#' @export
#' @method plot dependenciesGraphs
plot.dependenciesGraphs <- function(object, block = FALSE) {
visNetwork(object[[1]], object[[2]]) %>% visEdges(arrows = "from") %>% visOptions(highlightNearest = TRUE, nodesIdSelection = TRUE) %>%
visInteraction(dragNodes = !block) %>% visPhysics(solver = "repulsion", stabilization = list(enabled = FALSE, iterations = 5000,
onlyDynamicEdges = FALSE))
plot.dependenciesGraphs <- function(object, block = FALSE, width = NULL, height = NULL) {
visNetwork(object[[1]], object[[2]], width = width, height = height) %>%
visEdges(arrows = "from") %>%
visOptions(highlightNearest = TRUE, nodesIdSelection = TRUE) %>%
visInteraction(dragNodes = !block) %>%
visPhysics(solver = "repulsion", stabilization = list(enabled = FALSE, iterations = 5000, onlyDynamicEdges = FALSE))
}


Expand Down
17 changes: 14 additions & 3 deletions inst/Shiny/SERVER.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,27 @@ shinyServer(function(input, output, session) {

optionsDT_fixe$drawCallback <- I("function( settings ) {document.getElementById('tabledep').style.width = '400px';}")
## Output first graph
df <- data.frame(Function = func, Import = nb.func.master, `Imported by` = nb.func.slave)
df <- data.frame(Package = func, Import = nb.func.master, `Imported by` = nb.func.slave)



output$tabledep <- renderDataTable({
df
}, options = optionsDT_fixe)
# print(data)

output$main_plot <- renderVisNetwork({
plot(data, block = TRUE)
net <- plot(data, block = TRUE)

# add legend
data_legend <- unique(data2$fromto[, c("title", "color")])
data_legend$label <- gsub("<p>", "", data_legend$title, fixed = TRUE)
data_legend$label <- gsub("</p>", "", data_legend$label, fixed = TRUE)
data_legend$title <- NULL
data_legend$arrows <- "to"

net %>%
visLegend(addEdges = data_legend, useGroups = FALSE, width = 0.1)

})
curentd1 <<- data
output$titledatatabel <- renderText({
Expand Down
212 changes: 108 additions & 104 deletions inst/Shiny/UI.R
Original file line number Diff line number Diff line change
@@ -1,115 +1,119 @@
dashboardPage(
dashboardHeader(title = "DependenciesGraphs"),
dashboardSidebar( disable = TRUE),
dashboardSidebar(sidebarMenu(id = "Tabsetpan",
menuItem("Packages", tabName = "Packages", icon = icon("dashboard")),
conditionalPanel(condition = "input.Tabsetpan === 'Packages'",
selectInput('packages', "Package(s) :", choices = installed.packages()[,1], multiple = T, width = "100%"),
div(actionButton("GOPackage", "Go !",icon = icon("line-chart")), align = "center")
),
menuItem("Functions", tabName = "Functions", icon = icon("th")),
conditionalPanel(condition = "input.Tabsetpan === 'Functions'",
selectInput('package', "Package : ", choices = installed.packages()[,1], multiple = FALSE, width = "100%"),
div(actionButton("GOFunc2", "Go !",icon = icon("line-chart")), align = "center")
),
menuItem("Custom", tabName = "Custom", icon = icon("th"))

)),
dashboardBody(
# Boxes need to be put in a row (or column)
tags$head(tags$link(rel='stylesheet', type='text/css', href='style.css')),

tabsetPanel(id = "Tabsetpan", title = "Packages exploration", width = "100%",
# The id lets us use input$tabset1 on the server to find the current tab
tabPanel("Packages",
fluidRow(
column(3, div(h3('Package(s) selection :'), align = "center")),
column(6, br(), selectInput('packages', NULL, choices = installed.packages()[,1], multiple = T, width = "100%")),
column(3, br(), div(actionButton("GOPackage", "Launch",icon = icon("line-chart")), align = "center"))
),
hr(),

fluidRow(
box(
solidHeader = TRUE, collapsible = TRUE, title = "Dependencies between package(s)",
status = "primary",
visNetworkOutput("main_plot", width = "100%",height = "750px"),
br()
,width = 12
),
box(
solidHeader = TRUE, collapsible = TRUE, title = "Informations",
status = "primary",
div(
dataTableOutput("tabledep"),
uiOutput("Groupebutton"),
align="center"
),
width=12)
)

tabItems(
# First tab content
tabItem(tabName = "Packages",
# fluidRow(
# column(3, div(h3('Package(s) selection :'), align = "center")),
# column(6, br(), selectInput('packages', NULL, choices = installed.packages()[,1], multiple = T, width = "100%")),
# column(3, br(), div(actionButton("GOPackage", "Launch",icon = icon("line-chart")), align = "center"))
# ),
# hr(),

fluidRow(
box(
solidHeader = TRUE, collapsible = TRUE, title = "Dependencies between package(s)",
status = "primary",
visNetworkOutput("main_plot", width = "100%",height = "750px"),
br()
,width = 12
),
tabPanel("Functions",

fluidRow(
column(4, div(h3('Package :'), align = "center")),
column(4, br(), selectInput('package', NULL, choices = installed.packages()[,1], multiple = FALSE, width = "100%")),
column(4, br(), div(actionButton("GOFunc2", "Launch",icon = icon("line-chart")), align = "center"))
),
hr(),

fluidRow(
box(
solidHeader = TRUE, collapsible = TRUE, title = "Dependencies between functions",
status = "primary",
div(h4(textOutput("zoomin")), align = "center"),
visNetworkOutput("main_plot1", width = "100%",height = "750px"),
br()
,width = 12
),
box(
solidHeader = TRUE, collapsible = TRUE, title = "Informations",
status = "primary",
div(
# h4(textOutput("info")),
dataTableOutput("datatable2")
,align="center"
),
width=12)
),

fluidRow(
box(
uiOutput("help"),width = 12
)
)
box(
solidHeader = TRUE, collapsible = TRUE, title = "Informations",
status = "primary",
div(
dataTableOutput("tabledep"),
uiOutput("Groupebutton"),
align="center"
),
width=12)
)

),
tabItem(tabName = "Functions",
fluidRow(
box(
solidHeader = TRUE, collapsible = TRUE, title = "Dependencies between functions",
status = "primary",
div(h4(textOutput("zoomin")), align = "center"),
visNetworkOutput("main_plot1", width = "100%",height = "750px"),
br()
,width = 12
),
# tabPanel("Script",
#
#
# fluidRow(
# box(
# fileInput('file1', 'Choose R File',
# accept=NULL),
# visNetworkOutput("plotscript", width = "100%",height = "700px")
# ,width = 12)
# )
# ),

tabPanel("Custom",


fluidRow(
box(
fluidRow(
column(width=4,
selectizeInput(inputId = "packageslist" , "Package(s) :", choices = installed.packages()[,1], multiple = TRUE)
),
column(width=2,
br(), div(actionButton("chargedf", "Find functions", style = "padding: 8px 20px 8px 20px;"),align="center")
),
column(width=4,
selectizeInput(inputId = "functionlist" , "Function(s) :", choices = NULL, multiple = TRUE)
),
column(width=2,
br(), div(actionButton("makegraph", "Make graph", style = "padding: 8px 20px 8px 20px;"),align = "center")
)
),

hr(),
visNetworkOutput("chossefunctionplot", width = "100%",height = "750px"),
br(),
width = 12)
)
box(
solidHeader = TRUE, collapsible = TRUE, title = "Informations",
status = "primary",
div(
# h4(textOutput("info")),
dataTableOutput("datatable2")
,align="center"
),
width=12)
),

fluidRow(
box(
uiOutput("help"),width = 12
)


)
),
# tabPanel("Script",
#
#
# fluidRow(
# box(
# fileInput('file1', 'Choose R File',
# accept=NULL),
# visNetworkOutput("plotscript", width = "100%",height = "700px")
# ,width = 12)
# )
# ),

tabItem(tabName = "Custom",


fluidRow(
box(
fluidRow(
column(width=4,
selectizeInput(inputId = "packageslist" , "Package(s) :", choices = installed.packages()[,1], multiple = TRUE)
),
column(width=2,
br(), div(actionButton("chargedf", "Find functions", style = "padding: 8px 20px 8px 20px;"),align="center")
),
column(width=4,
selectizeInput(inputId = "functionlist" , "Function(s) :", choices = NULL, multiple = TRUE)
),
column(width=2,
br(), div(actionButton("makegraph", "Make graph", style = "padding: 8px 20px 8px 20px;"),align = "center")
)
),

hr(),
visNetworkOutput("chossefunctionplot", width = "100%",height = "750px"),
br(),
width = 12)
)
)


)
)
)
Expand Down
Loading

0 comments on commit 3c33e2a

Please sign in to comment.