Include the 'Calculating' Status Indicator in the Shiny App

I'm currently developing a web application using shiny. Some of the steps in my app require time-consuming calculations, so I want to implement a calculation in process indicator within the shiny application.

During my search, I came across a helpful resource on stackoverflow titled Show that Shiny is busy (or loading) when changing tab panels. However, it seems like the shinyIncubator package requires specifying minimum and maximum values.

Fortunately, I stumbled upon a blog post at , which presented an excellent method to achieve this.

shinyUI(bootstrapPage(
  # Adding custom CSS & JavaScript;
  tagList(
    tags$head(
      tags$link(rel="stylesheet", type="text/css",href="style.css"),
      tags$script(type="text/javascript", src = "busy.js")
    )
  ),
  div(class = "busy",  
      p("Calculating..."), 
      img(src="http://imageshack.us/a/img827/4092/ajaxloaderq.gif")
  ),
  div(class = "span4", uiOutput("obs")),
  div(class = "span8", plotOutput("distPlot"))
))

Javascript:

setInterval(function(){
  if ($('html').attr('class')=='shiny-busy') {
    setTimeout(function() {
      if ($('html').attr('class')=='shiny-busy') {
        $('div.busy').show()
      }
    }, 1000)
  } else {
    $('div.busy').hide()
  }
}, 100)

style.css

div.busy { 
  position:absolute;
  top: 40%;
  left: 50%;
  margin-top: -100px;
  margin-left: -50px;
  display:none;
  background: rgba(230, 230, 230, .8);
  text-align: center;
  padding-top: 20px;
  padding-left: 30px;
  padding-bottom: 40px;
  padding-right: 30px;
  border-radius: 5px;
}

My question now is, how can I incorporate custom CSS and Javascript into my ui file? I initially tried creating separate files for the JS and CSS, but encountered an issue where the indicator would always appear at the top left corner. I then attempted to directly input these codes into R, resulting in syntax errors. Any advice would be greatly appreciated!

Solution Found: Simply create a folder named "www" and place both files inside it.

Answer №1

To organize your files, make a new folder named "www" and place both of the files inside.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Performing a Mongoose query using the "find" method on multiple fields at once

I am currently developing an API using Node.js, Express, and MongoDB for a product available in the market. Each product has a title, brand, image, quantity, and other details. Our goal is to allow users to search for products by both title and brand in a ...

Utilizing Tidyverse for extracting lm()-residuals by specifying a subset of columns as predictors while retaining all columns in the output

In my dataset, I have the following data: dat = tibble( var1 = rep(c('A','B'),each=5) , var2 = rnorm(10) , var3 = rnorm(10) , var4 = rnorm(10) , var5 = rnorm(10) ) To achieve my desired outcome, I can explicitly s ...

Learn how to create a web application by utilizing HTML5 and REST, and then seamlessly transfer the front-end code to a mobile app using Cordova

Can a mobile application be developed from a web portal using Cordova or similar frameworks? The web portal will consist of: HTML5 for front-end J2EE for back-end with JAX-RS Is it feasible to extract pages from the web portal and integrate them into a ...

Applying CSS dynamically to a mat-cell in Angular 6

In my material table, I need to apply specific CSS classes based on the content of the cell. https://i.sstatic.net/YN6EO.png These are the CSS classes that I am using .status-code{ flex: 0 0 10% !important; width: 10% !important; } .status-code- ...

I need to retrieve data from two different databases. What is the best way to combine the code into a single function?

I am working on fetching data from 2 database sources and combining them to send the merged data to result.html function showResult(req, res){ var n = req.query.query mysql_conn.query('SELECT query_text FROM catalogsearch_query WHERE ...

Understanding the significance of the argument in the context of `express.json({ extended: false})`

Currently, I am in the process of setting up an API using express and encountered this particular line of code: app.use(express.json( { extended: false } )); Although I have referred to the documentation provided by express, I was unable to locate this sp ...

Main focus: Implementing dynamic data writing in this particular code scenario

Having trouble dynamically writing data inside my HTML table using JavaScript. As a newcomer to frontend development, specifically JS, I am seeking guidance on making this work smoothly. I've attempted methods like .innerHTML and .innerText without mu ...

Combining strings using the PHP preg_replace function

I'm looking for assistance with using Ajax to send JS variables to my PHP script in order to modify the background color. Can you provide guidance on how to achieve this? I am struggling with how to concatenate strings and utilize the $mavariable vari ...

The time that was constructed is not a valid function

I am currently working on a puppeteer script that interacts with my browser extensions and navigates to a specific page. It clicks on a particular extension button and fills in an input. Unfortunately, I am encountering an issue with the following error me ...

What is the best way to increase a specific value in an array of objects once it has been located (using findOne()), but before it is

I'm looking for a more efficient way to update an object within an array of schemas in one database request instead of two. Currently, I use findOneAndUpdate() to increment the field if the object already exists, and then I have to use update() if the ...

Customize the color of plot points in R highcharter based on their values

I'm diving into the world of highcharts and R highcharter for the first time. Currently, I have a dataframe structured like this: tmp <- data.frame(x = 1:5, y = rnorm(5), color = c("green", "red", "green", "orange", "red")) # x y color # 1 ...

Click to activate the Selectfield option

There are 3 links that populate the select field with various options. When the text label is active and someone clicks on the link selectlist1 or another, it should activate the select label. How can this be achieved? <!doctype html> <html> ...

Using column names as arguments in a function

I'm currently facing a challenge with non-standard evaluation, specifically regarding passing a variable name as an argument into a function. To illustrate, let's consider finding the mean of a single variable, mpg, from the mtcars dataset. My u ...

Displaying a specific fieldset based on the radio button selection

I have created a form to handle user input using PHP, with the initial question prompting the user to choose from three radio buttons for the "type" parameter - the options being "book", "journal", and "website". Here is what the code looks like: <stro ...

Is it true that all events in JavaScript go through capturing and bubbling phases?

My current project involves binding one eventListener to an <audio> element for the play event and another eventListener to its parent element for the same event. I've observed that the callback for the child element always gets executed, while ...

Ways to reposition Material UI tabs at the base of a container such as AppBar?

I'm looking for advice on how to position <Tabs within an AppBar at the bottom of a parent container, effectively placing them at the bottom of the header. Currently, I have divided the header into three sections: top-bar-left, top-bar-tabs, and to ...

What could be the reason for the malfunction of my checkbox styling?

I have designed custom checkboxes and radio buttons with CSS styling as shown below: input[type="checkbox"]:checked + label:after, input[type="checkbox"][checked="checked"] + label:after, input[type="radio"][checked="checked"] + label:after, input[type="r ...

Error in Charts API - [draw function failed to render for one or more participants]

Currently encountering an error on the client side where one or more participants failed to draw. I am able to successfully output data in the drawVisualization call, indicating that the issue lies within the JavaScript code. Despite following examples, I ...

Guide on swapping out a script file load with an Ajax request in JavaScript (utilizing YQL and JavaScript)

!!! The question below has been answered with a great example by Andrew Whitaker. Essentially, you can use the $.getJSON(..) method to fetch JSON data programmatically from a service like YQL. It's important to note that this service may be associated ...

Having trouble with jQuery's getJSON function throwing an error?

I have been working on a project where I am using the getJSON function to fetch JSON data from an API that I am developing. However, I am facing an issue where the getJSON function always triggers the error handler. Below is the JavaScript code I am using: ...