Spaces:
Running
Running
Update app.R
Browse files
app.R
CHANGED
@@ -5,6 +5,15 @@ library(shiny)
|
|
5 |
library(dplyr)
|
6 |
library(fields) # For image.plot in heatMap
|
7 |
library(akima) # For interpolation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
# Load the data from sm.csv
|
10 |
# Ensure 'sm.csv' is in the same directory as the app.R file or provide the full path.
|
@@ -267,7 +276,6 @@ ui <- fluidPage(
|
|
267 |
(function() {
|
268 |
const shareBtn = document.getElementById('share-button');
|
269 |
if (!shareBtn) return; // Exit if button not found
|
270 |
-
|
271 |
function showCopyNotification() {
|
272 |
const notification = document.createElement('div');
|
273 |
notification.innerText = 'Link copied!'; /* Shorter message */
|
@@ -285,11 +293,9 @@ ui <- fluidPage(
|
|
285 |
document.body.appendChild(notification);
|
286 |
setTimeout(() => { notification.remove(); }, 1500); /* Shorter duration */
|
287 |
}
|
288 |
-
|
289 |
shareBtn.addEventListener('click', function() {
|
290 |
const currentURL = window.location.href;
|
291 |
const pageTitle = document.title || 'Multiscale Explorer';
|
292 |
-
|
293 |
if (navigator.share) {
|
294 |
navigator.share({
|
295 |
title: pageTitle,
|
@@ -364,6 +370,12 @@ ui <- fluidPage(
|
|
364 |
# *** ADJUSTED PLOT OUTPUT ***
|
365 |
plotOutput("heatmapPlot", height = "500px", width = "100%")
|
366 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
367 |
# Use uiOutput for potentially HTML content in the note
|
368 |
uiOutput("contextNote")
|
369 |
)
|
@@ -611,7 +623,8 @@ server <- function(input, output, session) { # Add session argument
|
|
611 |
|
612 |
|
613 |
# *** ADJUSTED MARGINS AND COLORS ***
|
614 |
-
par(mar=c(5, 5, 4, 2) + 0.1) # Adjusted margins (bottom, left, top, right)
|
|
|
615 |
# *** USING HCL COLORS ***
|
616 |
customPalette <- hcl.colors(50, palette = "YlOrRd", rev = TRUE) # Or "Viridis", "Plasma" etc.
|
617 |
|
@@ -636,7 +649,11 @@ server <- function(input, output, session) { # Add session argument
|
|
636 |
legend.width = 1.5 # Slightly wider legend
|
637 |
)
|
638 |
|
639 |
-
},
|
|
|
|
|
|
|
|
|
640 |
|
641 |
# Contextual Note Output (using renderUI for HTML)
|
642 |
output$contextNote <- renderText({
|
|
|
5 |
library(dplyr)
|
6 |
library(fields) # For image.plot in heatMap
|
7 |
library(akima) # For interpolation
|
8 |
+
MAX_PLOT_DIM <- 600
|
9 |
+
safe_dim <- function(client_name, cap = MAX_PLOT_DIM) {
|
10 |
+
if (exists("session", inherits = TRUE)) { # Shiny context?
|
11 |
+
cd <- session$clientData[[client_name]]
|
12 |
+
if (!is.null(cd)) return(min(cap, cd)) # clamp to cap
|
13 |
+
}
|
14 |
+
cap # fallback
|
15 |
+
}
|
16 |
+
|
17 |
|
18 |
# Load the data from sm.csv
|
19 |
# Ensure 'sm.csv' is in the same directory as the app.R file or provide the full path.
|
|
|
276 |
(function() {
|
277 |
const shareBtn = document.getElementById('share-button');
|
278 |
if (!shareBtn) return; // Exit if button not found
|
|
|
279 |
function showCopyNotification() {
|
280 |
const notification = document.createElement('div');
|
281 |
notification.innerText = 'Link copied!'; /* Shorter message */
|
|
|
293 |
document.body.appendChild(notification);
|
294 |
setTimeout(() => { notification.remove(); }, 1500); /* Shorter duration */
|
295 |
}
|
|
|
296 |
shareBtn.addEventListener('click', function() {
|
297 |
const currentURL = window.location.href;
|
298 |
const pageTitle = document.title || 'Multiscale Explorer';
|
|
|
299 |
if (navigator.share) {
|
300 |
navigator.share({
|
301 |
title: pageTitle,
|
|
|
370 |
# *** ADJUSTED PLOT OUTPUT ***
|
371 |
plotOutput("heatmapPlot", height = "500px", width = "100%")
|
372 |
),
|
373 |
+
|
374 |
+
# *** ADDED VERTICAL SPACE ***
|
375 |
+
br(), # Add a line break for spacing
|
376 |
+
# OR use a div with margin:
|
377 |
+
tags$div(style="margin-bottom: 80px;"), # Alternative way to add space
|
378 |
+
|
379 |
# Use uiOutput for potentially HTML content in the note
|
380 |
uiOutput("contextNote")
|
381 |
)
|
|
|
623 |
|
624 |
|
625 |
# *** ADJUSTED MARGINS AND COLORS ***
|
626 |
+
#par(mar=c(5, 5, 4, 2) + 0.1) # Adjusted margins (bottom, left, top, right)
|
627 |
+
par(mar=c(5.1, 4.1, 3.1, 4.1)) # Margins: bottom, left, top, right
|
628 |
# *** USING HCL COLORS ***
|
629 |
customPalette <- hcl.colors(50, palette = "YlOrRd", rev = TRUE) # Or "Viridis", "Plasma" etc.
|
630 |
|
|
|
649 |
legend.width = 1.5 # Slightly wider legend
|
650 |
)
|
651 |
|
652 |
+
},
|
653 |
+
width = function() safe_dim("output_heatmapPlot_width"),
|
654 |
+
height = function() safe_dim("output_heatmapPlot_height"),
|
655 |
+
res = 96,
|
656 |
+
execOnResize = TRUE) # Adjust resolution if needed
|
657 |
|
658 |
# Contextual Note Output (using renderUI for HTML)
|
659 |
output$contextNote <- renderText({
|