-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.R
150 lines (142 loc) · 3.92 KB
/
test.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
library(shiny)
library(ggplot2)
# Define UI for the Shiny app
ui <- fluidPage(
tags$style(HTML("
body {
margin: 0;
font-family: Arial, sans-serif;
display: flex;
flex-direction: column;
height: 100vh;
}
#main-chart-container {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 30vh; /* Adjust the height according to your preference */
background-color: #003366; /* Main chart background color */
z-index: 10;
display: flex;
align-items: center;
padding: 20px;
box-sizing: border-box;
color: white;
}
#main-chart {
flex: 3;
text-align: center;
}
#main-chart-info {
flex: 1;
background-color: #004080; /* Adjust as needed */
padding: 20px;
box-sizing: border-box;
height: 100%;
overflow-y: auto;
}
#deep-dive-section {
margin-top: 30vh; /* Same as main chart height */
display: flex;
height: 70vh;
}
#deep-dive-charts {
flex: 1;
overflow-y: scroll;
padding: 20px;
background-color: #f4f4f4; /* Background for the deep-dive charts section */
}
.deep-dive-chart {
margin-bottom: 20px;
padding: 20px;
background-color: white;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
#info-box {
width: 300px;
background-color: #eaeaea;
padding: 20px;
box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
position: fixed;
top: 30vh; /* Below the main chart */
right: 0;
height: 70vh; /* Match the deep-dive section height */
overflow-y: auto;
}
")),
# Main chart output
tags$div(
id = "main-chart-container",
tags$div(
id = "main-chart",
plotOutput("main_chart")
),
tags$div(
id = "main-chart-info",
h2("Explanation"),
p("This is a brief explanation of the main indicator chart.")
)
),
# Deep-dive charts and information box
tags$div(
id = "deep-dive-section",
tags$div(
id = "deep-dive-charts",
div(
class = "deep-dive-chart",
h2("Deep-Dive Chart 1"),
plotOutput("deep_dive_chart1")
),
div(
class = "deep-dive-chart",
h2("Deep-Dive Chart 2"),
plotOutput("deep_dive_chart2")
),
div(
class = "deep-dive-chart",
h2("Deep-Dive Chart 3"),
plotOutput("deep_dive_chart3")
)
),
tags$div(
id = "info-box",
h2("Information Box"),
p("Detailed information about the deep-dive charts.")
)
)
)
# Define server logic required to draw charts
server <- function(input, output) {
# Main chart
output$main_chart <- renderPlot({
ggplot(mpg, aes(displ, hwy)) +
geom_point() +
ggtitle("Main Indicator Chart") +
theme_minimal() +
theme(
plot.background = element_rect(fill = "#003366", color = NA),
plot.title = element_text(color = "white", size = 16, face = "bold"),
axis.text = element_text(color = "white"),
axis.title = element_text(color = "white")
)
})
# Deep-dive charts
output$deep_dive_chart1 <- renderPlot({
ggplot(mpg, aes(class, hwy)) +
geom_boxplot() +
ggtitle("Deep-Dive Chart 1")
})
output$deep_dive_chart2 <- renderPlot({
ggplot(mpg, aes(manufacturer, cty)) +
geom_bar(stat = "identity") +
ggtitle("Deep-Dive Chart 2")
})
output$deep_dive_chart3 <- renderPlot({
ggplot(mpg, aes(year, hwy)) +
geom_line() +
ggtitle("Deep-Dive Chart 3")
})
}
# Run the application
shinyApp(ui = ui, server = server)