score:1

Accepted answer

I guess you can just stick to the shiny logic and its reactive values. Check if this meets your needs:

library(shiny)
library(shinydashboard)
library(shinyWidgets)
library(dplyr)
library(tidyr)
library(shinyjs)
library(shinycssloaders)
library(shinytoastr)
library(highcharter)
library(pool)

ui <- fluidPage(
  shinyjs::useShinyjs(),
  # Main panel for displaying outputs ----
  mainPanel(
    highchartOutput("Plot", height = 600),
    actionButton(inputId = "btn1", label = "increase width", class = "btn-primary"),
    actionButton(inputId = "btn2", label = "decrease width", class = "btn-primary")
  )
)

server <- function(input, output) {

  size <- reactiveVal(1)

  observeEvent(input$btn1, {
    size(size() + 1)
  })

  observeEvent(input$btn2, {
    # do not allow negative values
    if(size() > 0){
      size(size() - 1)
    } 
  })

  ########### Plot1 ##########

  output$Plot <- renderHighchart ({

    highchart() %>%
      hc_chart(type = "container",
               zoomType= "x"
      ) %>%
      #axis
      hc_xAxis(type='datetime',
               # categories=c(min2$datetime),
               labels = list(rotation = 90,
                             format = '{value:%e-%b %H:%M}'),
               showLastLabel = TRUE
      ) %>% 
      hc_yAxis(opposite = FALSE, 
               title = list(text = "Call Success"),
               labels = list(format = "{value}%", style=list(fontSize='13px')), max = 100) %>% 
      hc_add_series(all_NoTime3, "spline", hcaes(x=datetime, y=percent, group=customer)
      )%>%
      hc_tooltip(valueDecimals = 1,
                 borderWidth=2,
                 xDateFormat= '<b> %y/%m/%d %H:%M:%S <b/>',
                 crosshairs = TRUE,
                 backgroundColor=' #eaecee ',
                 pointFormat = "Customer: <b> {series.name} <br> Success: <b> {point.y} %",
                 style=list(fontSize='14px')
      )%>%
      hc_plotOptions(spline =list(lineWidth = size(),
                                  allowPointSelect = TRUE,
                                  turboThreshold = 100,
                                  cursor = 'pointer',
                                  states = list(hover = list(lineWidth = 4)),
                                  marker = list(enabled = F,
                                              radius=1, 
                                              symbol="circle"))
      ) %>%
      hc_credits(enabled = TRUE,
                 text = "CX & SE Center",
                 style = list(fontSize = "10px")
      ) %>%
      hc_exporting(enabled = TRUE)
  }) 

}

shinyApp(ui, server)

Related Query

More Query from same tag