I use Highcharts and Shiny. I plotlines line to the x axis through the parameter plotlines . It is necessary to remove it, but I do not understand how to do it.
For JS there is a function RemovePlotLine("id") . Can I use it in R and how?
Code example:
usg_first <- read.table(file= "USG - 1k.csv",header=TRUE,sep=";") usg_fifth <- read.table(file= "USG - 5k.csv",header=TRUE,sep=";") if(!require(shiny)) install.packages("shiny") if(!require(highcharter)) install.packages("highcharter") if(!require(dplyr)) install.packages("dplyr") if(!require(tidyr)) install.packages("tidyr") library(shiny) library(highcharter) library(dplyr) library(tidyr) Av_usg <- c( mean(usg_first$Average_thickness_nm), mean(usg_fifth$Average_thickness_nm)) Sigm <- c(sd(usg_first$Average_thickness_nm)/sqrt(length(usg_first$Average_thickness_nm)),sd(usg_fifth$Average_thickness_nm)/sqrt(length(usg_fifth$Average_thickness_nm))) LCL <- c((Av_usg[1] - 3 * Sigm[1]), (Av_usg[2] - 3 * Sigm[2])) UCL <- c((Av_usg[1] + 3 * Sigm[1]), (Av_usg[2] + 3 * Sigm[2])) i <- 1 ui <- fluidPage( titlePanel("Статистическое управление процессом"), sidebarLayout( Here I set the drop-down list, when switching which lines should be updated.
# Лист с графиками selectInput("mat", label = "Пластина", choices = c("USG - 1k" = "first", "USG - 5k" = "fifth")), ), mainPanel( highchartOutput2("hcontainer2", height = "800px") ) ) ) # Создание сервера server = function(input, output) { # Настройка параметров графика output$hcontainer2 <- renderHighchart({ hc <- highchart() %>% hc_add_series(data = usg_first$Average_thickness_nm, type = input$plot_type, name = "Средняя толщина пластины, [нм]") %>% I want to delete this line on the Y axis:
hc_yAxis(title = list(text ="Средняя толщина пластины, [нм]"), allowDecimals = TRUE, plotLines = list(list( value = Av_usg[1], color = 'green', id = 'avg', width = 3, label = list(text = "Cреднее значение толщин", style = list(color = 'black', fontWeight = 'bold')) ))) %>% hc_xAxis(visible = FALSE) %>% if (input$mat != "first") { material <- switch(input$mat, first = usg_first, fifth = usg_fifth ) if (input$mat == "first"){i = 1} else {i = 2} hc <- hc %>% hc_rm_series("Средняя толщина пластины, [нм]")%>% Here you need to insert, that I delete the line on the Y axis.
hc$y$hc_opts$yAxis$plotLines[1]<- NULL hc_add_series(data = material$Average_thickness_nm, type = input$plot_type, name = "Средняя толщина пластины, [нм]", ShowInLegend = FALSE) } # Вывод графика hc }) } # Запуск shinyApp(ui = ui, server = server)