Freeze x-axis within chart Area R shiny

What can i add to the below piece of code to have the x-axis freeze so that it is always visible without the need of scrollling down to bottom

test_sites <- finaloutput %>% group_by(Location_Name) %>% slice(2)

test_df <- finaloutput #%>% filter(grepl('10731|7864|3113|3268|11566',Location_Name))

actcols <- c("#548235", "#2E75B6", "#BF9000", "#7030A0", "#cd6600",'#548235')

p_test <- ggplot(test_df, aes(colour= Timeline.Type, group = Location_Name)) +

geom_segment(aes(x=Timeline.Start, xend=Timeline.End, y=Location_Name, yend=Location_Name) , size=12) +

labs(x="Timeline Start", y="Location Name", title="Radar Gantt Chart") +

scale_color_manual(values=actcols, name="Timeline Type") +

theme_bw()+

theme(
text = element_text(color = "#993333" , size = 10, face = "bold"),
axis.line = element_line(colour = "black", size = 1, linetype = "solid"),
strip.background = element_blank(),
strip.text = element_text(hjust = 0),
panel.grid.major = element_line(colour="#e6e6e6",size=0),
panel.grid.minor = element_blank(),
plot.margin=unit(c(0,1,0,1),"cm"),
legend.position="right",
legend.title = element_text(size=12, color="#006a4d"),
legend.text = element_text(size=8, color="#69be28"),
axis.title.x = element_text(color="#006a4d", size=10, face="bold"),
axis.title.y = element_text(color="#006a4d", size=10, face="bold"),
axis.text = element_text(color = "black", size = 8, face="bold"),
axis.text.y=element_text(margin = margin(100, unit = "cm"),vjust =100),
plot.caption=element_text(hjust=5,size=30,colour="grey30" ),
plot.subtitle=element_text(face="italic",size=30,colour="grey40"),
plot.title=element_text(color="#006a4d",size=15,face="bold"))

p_test <- ggplotly(p_test)%>%
layout(legend = list(orientation ='v', x = 1.2, y = 1))

div(style= 'max-height:1000px; overflow-y: scroll; position: relative',
plotlyOutput(p_test))

if (interactive()) {
library(shiny)
library(bs4Dash)
shinyApp(
ui = bs4DashPage(
bs4DashNavbar(),
bs4DashSidebar(),
bs4DashControlbar(),
bs4DashBody(
fluidRow(
bs4Box(plotlyOutput('radar', height = 10000), width = 10),
bs4Box(img(src="bsc_logo.png", align = "right",height='10px'),width=2)

    ),
    mainPanel(plotlyOutput('trendplot', height = "500px"))

  ),
  title = "AttachmentBlock"
),

server = function(input, output) { 
  output$radar <- renderPlotly({
    ggplotly(p_test)
  })
  
  }

)
}

Hi,

Welcome to the RStudio community!

Issues with Shiny code can stem from both the reactive Shiny code itself or the regular R code used in the functions. In order for us to help you with your question, please provide us a minimal reproducible example (Reprex) where you provide a minimal (dummy) dataset and code that can recreate the issue. One we have that, we can go from there. For help on creating a Reprex, see this guide:

Good luck!
PJ

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.