Skip to content

Commit 474eee1

Browse files
committed
added athe format diapay dashboard tab
1 parent bff4b86 commit 474eee1

6 files changed

Lines changed: 151 additions & 19 deletions

File tree

NAMESPACE

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ export(cruzTickStart)
66
export(cruzTickUpdate)
77
export(cruz_box)
88
export(cruzplot_gui)
9+
export(mod_display_format_server)
10+
export(mod_display_format_ui)
911
export(mod_map_color_server)
1012
export(mod_map_color_ui)
1113
export(mod_map_elements_server)
@@ -31,6 +33,7 @@ importFrom(graphics,abline)
3133
importFrom(graphics,axis)
3234
importFrom(graphics,lines)
3335
importFrom(graphics,par)
36+
importFrom(graphics,points)
3437
importFrom(graphics,rect)
3538
importFrom(graphics,text)
3639
importFrom(graphics,title)

NEWS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# CruzPlot 2.0.0 (dev)
22

3-
* Provide a more information error message when CruzPlot cannot load a DAS file (#6)
3+
* CruzPlot now provides a more information error message when it cannot load a DAS file (#6)
44

5-
* Modularize CruzPlot shiny app (in progress) (#7)
5+
* Modularized the CruzPlot shiny app (in progress) (#7)
66

77

88
# CruzPlot 1.4.9

R/CruzPlot-package.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#' @import shiny
1313
#' @importFrom dplyr between case_when if_else
1414
#' @importFrom geosphere destPoint
15-
#' @importFrom graphics abline axis par lines rect text title
15+
#' @importFrom graphics abline axis par points lines rect text title
1616
#' @importFrom grDevices gray palette dev.off jpeg pdf png
1717
#' @importFrom maps map
1818
#' @importFrom shinydashboard box dashboardBody tabItems tabItem dashboardHeader

R/cruzplot_gui.R

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ cruzplot_gui <- function(...) {
3939
# menuItem("App State", tabName = "appstate", icon = icon("th", lib = "font-awesome")),
4040
# menuItem("Plot DAS Data", tabName = "DASplot", icon = icon("th")),
4141
# menuItem("Plot Non-DAS Data", tabName = "nonDASplot", icon = icon("th")),
42-
# menuItem(HTML(paste0("Color and Formatting", "<br/>", "Options")), tabName = "dispColor", icon = icon("th")),
43-
# menuItem("Species Information", tabName = "dispSp", icon = icon("th")),
44-
# menuItem("CruzPlot Manual", tabName = "dispManual", icon = icon("th")),
42+
menuItem(HTML(paste0("Color and Formatting", "<br/>", "Options")), tabName = "dispColor", icon = icon("th")),
43+
menuItem("Species Information", tabName = "dispSp", icon = icon("th")),
44+
menuItem("CruzPlot Manual", tabName = "dispManual", icon = icon("th")),
4545
tags$br(),
4646
fileInput("load_app_envir_file", "Load workspace"),
4747
column(
@@ -51,18 +51,12 @@ cruzplot_gui <- function(...) {
5151
),
5252
tags$br(), tags$br(), #tags$br(),
5353
numericInput("plot_height", "Map height (pixels)", value = 600, min = 0, step = 100),
54-
55-
# cruz_box(
56-
# title = "Color style", width = 6,
57-
# helpText("This color style selection will affect the palette options for all color selections in CruzPlot"),
58-
# tags$br(),
5954
selectInput(
6055
"color_style",
6156
"App-wide color style",
6257
choices = list("Color" = 1, "Gray scale" = 2),
6358
selected = 1
6459
),
65-
# ),
6660
tags$br(),
6761
actionButton("stop", "Close CruzPlot"),
6862
column(12, tags$h5(paste0("CruzPlot v", packageVersion("CruzPlot"))))
@@ -96,12 +90,6 @@ cruzplot_gui <- function(...) {
9690
});
9791
')),
9892
tabItems(
99-
# tabItem(
100-
# tabName = "appstate",
101-
# h3("Current App State"),
102-
# p("This panel shows the values stored in the central 'app_state' object."),
103-
# verbatimTextOutput("current_state_display")
104-
# ),
10593
tabItem(
10694
tabName = "createmap",
10795
fluidRow(
@@ -118,7 +106,8 @@ cruzplot_gui <- function(...) {
118106
mod_map_color_ui("map_color")
119107
)
120108
)
121-
)
109+
),
110+
mod_display_format_ui("display_format")
122111
)
123112
)
124113
)
@@ -196,6 +185,10 @@ cruzplot_gui <- function(...) {
196185
map_elements <- mod_map_elements_server("map_elements", load_state_map_elements, map_range)
197186
map_color <- mod_map_color_server("map_color", load_state_map_color, map_range)
198187

188+
#----------------------------------------------------------------------------
189+
### Display tabs
190+
mod_display_format_server("display_format")
191+
199192
#----------------------------------------------------------------------------
200193
### Plots
201194
# plot_height <- reactive(input$plot_height)

R/mod_display_format.R

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
#' Display format module
2+
#'
3+
#' Shiny module for displaying format and color options
4+
#'
5+
#' @name mod_display_format
6+
#'
7+
#' @inheritParams mod_plot
8+
#'
9+
#' @details
10+
#' This module displays the app color and format options, including:
11+
#' color palette options, line types, line widths, symbols, and fonts
12+
#'
13+
#' @returns The UI function returns a [shinydashboard::tabItem()] object
14+
#'
15+
#' The server function returns nothing
16+
#'
17+
#' @export
18+
mod_display_format_ui <- function(id) {
19+
ns <- NS(id)
20+
21+
tabItem(
22+
tabName = "dispColor",
23+
fluidRow(
24+
box(
25+
title = "Color/Format Options", status = "primary", solidHeader = TRUE, width = 12,
26+
plotOutput(ns("plot_display_format"))
27+
),
28+
column(12, actionButton(ns("display_redraw"), "Redraw display"))
29+
)
30+
)
31+
}
32+
33+
34+
#' @name mod_display_format
35+
#' @export
36+
mod_display_format_server <- function(id) {
37+
moduleServer(id, function(input, output, session) {
38+
cruzDisplaySymbolProp <- reactive({
39+
input$display_redraw
40+
41+
plot.max <- length(symbol.col) + length(symbol.col.gray) + 3
42+
plot.h1 <- plot.max - 1.5 + 1
43+
plot.h2 <- plot.max - 1.75 + 1
44+
plot.h3 <- plot.max - 1.85 + 1
45+
plot.h4 <- plot.max - 2 + 1
46+
plot.h5 <- plot.max - 3 + 1
47+
plot.h6 <- plot.max - 14 + 1
48+
49+
plot.gs <- plot.h3 - 1.15 - length(symbol.col)
50+
51+
oldpar <- par(mar = rep(1, 4), family = "sans")
52+
plot(c(0, 1), c(0, plot.max), type = "n", axes = FALSE, bty = "n")
53+
54+
# Top labels
55+
text(c(0.05, 0.32, 0.7, 0.95), rep(plot.h1, 4), c("Symbols", "Colors", "Line Types", "Widths"), cex = 1.4)
56+
#text(c(0.05,0.3,0.7,0.95),rep(26.5,4),c("(pch= )","(col= )","(lty= )","(lwd= )"),cex=1.3)
57+
58+
# Symbols
59+
for(i in 0:20) {
60+
text(0.02, plot.h5 - (i * 1.25), i, cex = 1)
61+
points(.08, plot.h5 - (i * 1.25), pch = i, cex = 1.8)
62+
}
63+
64+
# Colors used in CruzPlot
65+
for(i in 1:length(symbol.col)) {
66+
text(0.33, plot.h3 - (i + .25), symbol.col[i], cex = 1, pos = 2)
67+
points(.35, plot.h2 - (i + .25), pch = 15, cex = 2.1, col = symbol.col.code[i])
68+
}
69+
points(0.35, (plot.h2 - (length(symbol.col) + .25)), pch = 0, cex = 2.0) #puts box around white
70+
text(0.24, plot.max-13, "Color", srt = 90, cex = 1.2, pos = 4)
71+
72+
# Greyscale palette
73+
palette(gray((0:5) / 5))
74+
for(i in 1:6) {
75+
text(0.33, plot.gs - i, symbol.col.gray[i], cex = 1, pos = 2)
76+
points(0.35, plot.gs - i + 0.1, pch = 15, cex = 2.1, col = symbol.col.code.gray[i])
77+
}
78+
points(0.35, plot.gs - 6 + 0.11, pch = 0, cex = 2.0) #puts box around white
79+
text(0.24, 0.1, "Gray Scale", srt = 90, cex = 1.2, pos = 4)
80+
81+
# Line types
82+
for(i in 1:6) {
83+
text(0.55, plot.h5 - i, i, cex = 1.1)
84+
lines(c(0.6, 0.7, 0.85), c(plot.h5 - i, plot.h4 - i, plot.h4 - i), lty = i)}
85+
# line widths
86+
for(i in 1:6) {
87+
lines(c(0.9, 1), c(plot.h4 - i, plot.h4 - i), lwd = i)
88+
}
89+
90+
# Typefaces
91+
text(0.75, plot.h6, "Fonts", cex = 1.4)
92+
plot.h6b <- plot.h6 + 0.5
93+
for(i in 1:3) {
94+
i.m <- i * 1.5
95+
text(0.75, plot.h6b - 0.0 - (i.m * 2.3), names(font.family)[i], cex = 1.2, adj = 0.5, family = font.family.vals[i])
96+
text(0.75, plot.h6b - 0.9 - (i.m * 2.3), paste(LETTERS, collapse = ""), cex = 1, adj = 0.5, family = font.family.vals[i])
97+
text(0.75, plot.h6b - 1.8 - (i.m * 2.3), paste(c(letters, " ", 0:9), collapse = ""), cex = 1, adj = 0.5, family = font.family.vals[i])
98+
}
99+
100+
palette("default")
101+
par(oldpar)
102+
})
103+
104+
105+
output$plot_display_format <- renderPlot({
106+
cruzDisplaySymbolProp()
107+
})
108+
})
109+
}

man/mod_display_format.Rd

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)