Guidelines for Implementing Particle Animation in Your Shiny Application

I'm curious about implementing Particle-animation in the background of my Shiny app, similar to the effects in

Here's the current state of my Shiny code.

ui.R

library(shiny)

fluidPage(
    tagList(tags$head(includeCSS("CSS.css"), includeScript("particles.js"), includeScript("JS.js"))),

    div(div(id = 'particles-js'), selectInput("Dummy", "Some Dummy number:",c(1,2,3)))
)

server.R

server <- function(input, output) {

}

CSS.css

#particles-js {
  width: 100%;
  height: 100%;
  background: rgba(0,53,107, 0.3);
}

JS.js

particlesJS("particles-js", {
    particles: { 
        // particle settings
    },
    interactivity: { 
        // interactivity settings
    },
    retina_detect: true
});

Unfortunately, the current code does not integrate the Particle animation into my Shiny app background.

I would greatly appreciate any guidance in the right direction.

Thank you,

Answer №1

A potential solution based on the suggestion provided in this source is outlined below:

ui.r

ui <- fluidPage(
    tagList(
    tags$head(tags$script(src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="44342536302d272821376a2e3704766a746a746a">[email protected]</a>/particles.min.js")),
    tags$head(includeCSS("CSS.css")),
    includeScript("app.js")),   
    div(div(id = 'particles-js'), selectInput("Dummy", "Some Dummy number:",c(1,2,3)))  
)

app.js

particlesJS.load('particles-js', 'particles.json');

particles.json

{
  "particles": {
    "number": {
      "value": 80,
      "density": {
        "enable": true,
        "value_area": 800
      }
    },
    "color": {
      "value": "#ffffff"
    },
    "shape": {
      "type": "circle",
      "stroke": {
        "width": 0,
        "color": "#000000"
      },
      "polygon": {
        "nb_sides": 5
      },
      "image": {
        "src": "img/github.svg",
        "width": 100,
        "height": 100
      }
    },
    "opacity": {
      "value": 0.5,
      "random": false,
      "anim": {
        "enable": false,
        "speed": 1,
        "opacity_min": 0.1,
        "sync": false
      }
    },
    "size": {
      "value": 10,
      "random": true,
      "anim": {
        "enable": false,
        "speed": 80,
        "size_min": 0.1,
        "sync": false
      }
    },
    "line_linked": {
      "enable": true,
      "distance": 300,
      "color": "#ffffff",
      "opacity": 0.4,
      "width": 2
    },
    "move": {
      "enable": true,
      "speed": 12,
      "direction": "none",
      "random": false,
      "straight": false,
      "out_mode": "out",
      "bounce": false,
      "attract": {
        "enable": false,
        "rotateX": 600,
        "rotateY": 1200
      }
    }
  },
  "interactivity": {
    "detect_on": "canvas",
    "events": {
      "onhover": {
        "enable": false,
        "mode": "repulse"
      },
      "onclick": {
        "enable": true,
        "mode": "push"
      },
      "resize": true
    },
    "modes": {
      "grab": {
        "distance": 800,
        "line_linked": {
          "opacity": 1
        }
      },
      "bubble": {
        "distance": 800,
        "size": 80,
        "duration": 2,
        "opacity": 0.8,
        "speed": 3
      },
      "repulse": {
        "distance": 400,
        "duration": 0.4
      },
      "push": {
        "particles_nb": 4
      },
      "remove": {
        "particles_nb": 2
      }
    }
  },
  "retina_detect": true
}

CSS.css

#particles-js  canvas{
  position: absolute;
  width: 100%;
  height: 100%;
  background: rgba(0,53,107, 0.3);
  z-index: -1;
}

The app.js and particles.json files should be placed in the www directory within Shiny (

C:\Users\<user>\Documents\R\win-library\3.4\shiny\www
for Windows 7).

https://i.sstatic.net/LnUAq.png

Answer №2

Integrate dynamic animations into your projects by leveraging the shinyparticles package available on Github.

ui <- fluidPage(
       particles(),
       headerPanel("Check out this interactive app")
      )
server <- function(input, output, session){}

shinyApp(ui, server)

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

Utilizing a Promise in NodeJS and Express to effectively capture the writing functionality of the HTTP module

Currently, I am in the process of developing an Express application with the following components: NodeJS v8 express (latest version) As I delved into the workings of the onHeaders module and observed how it alters the HTTP headers, I became keen on lev ...

How can I adhere to Angular 2's naming convention for Input and Output as suggested by the styleguide?

Working with inputs and outputs while following Angular 2's styleguide naming convention Initially, my directive was defined like this: ... inputs: [ 'onOutside' ] ... export class ClickOutsideDirective { @Output() onOutside: EventEmitter ...

What is the process for node_modules packages to access configuration files located in the project root directory?

I am currently developing an npm package that requires the ability to access configuration files from the project's root directory. I'm uncertain of the proper method for accomplishing this. For instance, Next.js has the capability to read ./p ...

Android is now asking for location permissions instead of Bluetooth permissions, which may vary depending on the version

I am currently troubleshooting a React Native application that relies heavily on Bluetooth permissions. However, I am encountering an issue with the Android platform where the Bluetooth permissions are appearing as unavailable. I have configured the permi ...

Incorporating Material-UI with React Searchkit for a seamless user experience, featuring

I encountered an issue when trying to use both searchkit and material-ui in my React application. The problem arises from the fact that these two libraries require different versions of reactjs. Initially, everything was working fine with just searchkit in ...

"encountered net::ERR_NAME_NOT_RESOLVED error when trying to upload image to s3 storage

I am currently developing an application using Angular. I have been attempting to upload a picture to my S3 bucket, but each time I try, I encounter this error in the console. https://i.stack.imgur.com/qn3AD.png Below is the code snippet from my upload.s ...

Acquire the worth of the <MenuItem> element from React's mui/material library

I am attempting to retrieve the value of the selected item listed below: Here is my attempt at logging this information: console.log("Event: ", event.currentTarget); Output: <li class="MuiButtonBase-root MuiMenuItem-root MuiMenuItem-gut ...

What is the most effective method for dynamically showcasing buttons in AngularJS?

Hello all, I'm currently learning AngularJS and I was wondering if anyone could recommend the simplest and most effective method for dynamically displaying links from AngularJS to HTML. I am looking to display a variable number of buttons in my HTML ...

Is it possible to launch a Nextjs app on Vercel for production purposes? How well does it handle high volumes of traffic?

As a newcomer to Nextjs, I am looking to deploy my app to production. I'm curious about whether Vercel can effectively handle heavy traffic on the site. Should I consider utilizing platforms such as AWS or GCP for deployment instead? Any advice would ...

The Tailwind preset is generating CSS code, but the webpage is not displaying the intended styles

Can anyone explain why the preset is generating CSS in the output file, but the styles are not displaying in the browser? When I manually write CSS in newstyle.css, it gets outputted to output.css and renders correctly in the browser. I attempted adding t ...

What is the most effective method for displaying a child modal within a map?

Project link: Check out my project here! I have two key files in my project - App.js and PageFive.js. In App.js, there is an array defined as follows: state = { boxes: [ { cbIndex: "cb1", name: "Bob" }, { cbI ...

"Explore a different approach to file uploading with React Native JavaScript by using either blob or base64 encoding

I am in the process of uploading visuals. When I employ this technique, it functions as expected: formData.append("file",{uri,type,name}); Yet, I prefer not to transmit my visual using the URI. My intention is to divide the visual into distinct sections ...

What is the best way to extract a subset of a phyloseq object for conducting ancombc analysis in R

I was attempting to follow a tutorial on ANCOMBC that can be found at However, I encountered a problem right at the start when I couldn't figure out how to subset the atlas file. The code snippet I used is as follows: data(atlas1006) tse = atlas1006 ...

Recalling a hidden div in a flexbox arrangement

I am facing a challenge with hiding and displaying two aside divs to enable a fullscreen view of my central div main. The layout is created using flexbox to assign proportions, but when I try to redisplay the elements, it disrupts the original design. Belo ...

Serving Files in Express JS: the benefits of serving files directly from memory compared to serving static

Should I keep images and other assets in memory or serve them from static assets? Will often-requested static assets be stored in memory? Does anyone have insight into the performance implications of this decision? ...

Iterate over the controls within an UpdatePanel, and interact with JavaScript functions

I'm attempting to change all TextBoxes into labels on my page using the following code: foreach (Control ctrl in masterform.Controls) { if (ctrl.GetType() == typeof(TextBox)) { TextBox t = ctrl as TextBox; t.ReadOnly = true; ...

Is there a way to divide a single array into two separate arrays based on a specific element?

My goal is to create an interactive graph using plotly.js. I have an array named data that contains all the information needed for the graph. However, I want users to be able to select specific elements to display on the graph. To achieve this functionalit ...

Error encountered with the Schema in expressjs and mongoose frameworks

I am currently working on integrating mongoDB with an expressjs project using mongoose, and I have encountered a specific error. throw new mongoose.Error.MissingSchemaError(name); ^ MissingSchemaError: Schema hasn't been registered for model ...

Switch the functionality of a Google Chrome extension back and forth numerous times

My Google Chrome extension works by attaching event listeners to all elements on a page and inserting CSS (lol.js and style.css) when clicked. However, I am facing an issue where I cannot remove the JS and CSS upon clicking the icon again. Right now, I am ...

Retrieve the input data following validation of an AngularJS form

Hello there! I am relatively new to utilizing AngularJS and Bootstrap. Recently, I have created a login form using AngularJS and Bootstrap CSS. Below you will find the code for my form: <form name="userForm" ng-submit="submitForm(userForm.$valid)" nova ...