shinyjs | 💡 Easily improve the user experience | Data Visualization library
kandi X-RAY | shinyjs Summary
kandi X-RAY | shinyjs Summary
Easily improve the user experience of your Shiny apps in seconds
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of shinyjs
shinyjs Key Features
shinyjs Examples and Code Snippets
Community Discussions
Trending Discussions on shinyjs
QUESTION
I have a shiny dashboard that displays various elements (highchart and ggplot plots, datatables). Users can filter by some variables to create a "groupA" and groupB" of data. GroupA is initially all the data, GroupB is empty initially. When the user opens the dashboard, they will see a single column of elements for GroupA. By filtering they are able to move some data to groupB, which should show in new 2nd column. So each of group A and B have the same elements on the page, just a different filter is applied. If groupB becomes empty, the view will again switch to a single column of groupA elements. The column for GroupA should resize as needed to cover the whole width or half the width. I am having difficulty getting this to work in a way that is economical on code.
The answer here uses element IDs to show and hide specific elements. This would work but the dashboard has many pages and many elements per page. So it would involve a large amount of additional code.
I thought that just by putting each element in a div with class corresponding to the group, that I would be able to apply the same idea, except to use a CSS selector and catch all elements in one go. But this is not working. The CSS selector seems OK, e.g. when I use it in a jQuery statement in the console I get the expected elements.
The code below is a reprex of the issue just with buttons to show/hide groupB for simplicity, rather than depending on the data.
...ANSWER
Answered 2022-Mar-14 at 23:49The problem is for both removeClass
and addClass
, the first positional argument is id
, not class.
To make it work as the class you want to add/remove, you need to write the argument name class = xxx
out:
QUESTION
I have read this article on tagQuery and was left wondering what could be the practical use in a shiny app.
Is it to modify a tag on the server side in a way similar to shinyjs::addClass()
?
ANSWER
Answered 2022-Mar-09 at 16:52I think it’s mostly useful when you need to modify or extract parts of a potentially deeply nested HTML structure. Such a need may arise in particular in cases where you don’t have control over creating the original structure, but rely on a package to do that for you.
For a real example, this old answer of mine
could benefit from using tagQuery()
.
As the setup, we have a dynamically generated menu. There, we want to add
an id
attribute to the ul
element inside, in order to be able to later
target that element with JavaScript.
QUESTION
My application server file looks like this :
...ANSWER
Answered 2022-Mar-09 at 15:12The following script creates two shiny apps:
The child_app
is running in a seperate background R process (depending on how you deploy your app this might not be needed), which can be controlled (filtered) via query strings.
The parent_app
displays the child_app
in an iframe
and changes the query string (iframe
's src
) depending on the user accessing the app (permission level):
QUESTION
I need some clarification on how to properly send queries to my database within RShiny...
I have build-up an application in which anyone can create an account and then write some informations in a dataframe before saving those rows to my database.
The app works perfectly well when testing my it with a single user but shows some issues when several users send data to my database at the same time. All the informations sends are duplicated 2 to 10 times in postgresql...
For instance if I add an unique observation of 5 individuals of species "A" with an observation date on the 25th of february I will get 3 rows (sometimes it can be up to 10 duplicates) in my database instead of one. (like shown in the table below):
...ANSWER
Answered 2022-Mar-08 at 09:57Below please find a reproducible example using library(RSQLite)
- just switch back to your postgres connection / schema.
I don't think the issue is pool
related. I guess (I can't verify without your DB) your call to rbind
is problematic - as it sends multiple lines if the reactiveVal
was used before.
Furthermore, in a case like this it is much more efficient to create a cross-session reactive (here reactivePoll
) to share the DB information among sessions, instead of having each session query the DB every second.
QUESTION
In the below reproducible code, two main conditional panels are presented: "Stratification" and "DnL balances". The first presents a smaller data table where no scroll bars are automatically introduced, and the 2nd presents a larger data table where scroll bars are introduced.
The scroll bars in one conditional panel appear to be affecting the other conditional panel. I have tried addressing with style = "display: none;"
(based on a related post yesterday), flagged with ### in this reproducible code, but it leaves the 2nd conditional panel without the glide/well panel across the top unless the user adjusts the size of the window, however minutely. Yesterday's posted solution worked fine, but that code didn't render a data table. When introducing a data table and resulting scroll bars, the issue manifests.
Is there a way to resolve this? May be a hack, but even a tiny automated adjustment to the size of the window may help?
The images at the bottom better explain the issue.
...ANSWER
Answered 2022-Mar-07 at 10:42Edit: The dev-version is already fixed:
remotes::install_github("juba/shinyglide")
should resolve the issue.
Initial answer:
Regarding shinyglide's behaviour I filed an issue here.
Using library(DT)
you could avoid the long output which leads to the vertical scrollbar:
QUESTION
I make making a Shiny app in R that shows the user an Excel-like grid. The excelR
package is a wrapper for a JS package JSpreadsheet. This package automatically puts row numbers in the left-most column. I do not want them.
By digging into the JavaScript, I was finally able to figure out how to use an actionButton to remove the row numbers by sending a JS command:
...ANSWER
Answered 2022-Mar-07 at 10:27I modified your example to make it more discrete, however it will run every time someone modify your app (because of the observe()
function).
QUESTION
I created several two inputs in the UI: "slider0" and "slider1" and one in the server using renderUI "slider2". I am trying to use calculate a new column of a data-frame based on a conditional statement on slider0 and the values of slider1 and slider2.
I have the following reproducible code:
...ANSWER
Answered 2022-Mar-05 at 09:41You could req
uire that input$server2
is defined and has a valid value before using it further:
QUESTION
I'm having trouble with the formats of conditional panels affecting other conditional panels. Below is reproducible code, and at the bottom are images better explaining the issue. In the fuller App this code derives from, the problem is more obvious and makes it look sloppy (in the fuller App, there are multiple screens the user clicks through as the user scrolls to the right along the shaded bar (Well Panel) at the top just underneath the tab label, and the misalignment gets more pronounced as the user scrolls to the right).
The problem is: as the user scrolls right through the Glide Controls / Well Panels to make selections, the Well Panels (at the top with radio buttons) begin to misalign with the table and/or plots that appear beneath. The misalignment gets more pronounced as the user scrolls right. This misalignment isn't as apparent in this reproducible example, but is more pronounced in the fuller App this derives from where there are multiple "screens" or Well Panels at the top for the user to scroll through and where there are data tables and/or plots presented underneath in the main panel.
For sake of simplicity all server code is eliminated in this example (no plots, no tables), as the issue still presents without the server code.
If I comment-out other conditional panels (marked "###" in the reproducible code) the misalignment goes away. So how can I make the conditional panels independent of one another, as a way of eliminating this misalignment? I'm open to any other suggestions for eliminating this misalignment.
The basic structure of the App is the user makes "big choices" along the sidebar panel, and makes more "refined choices" only the top bar underneath the tab label using Glide Controls/Well Panels etc. for a carousel affect.
Reproducible code:
...ANSWER
Answered 2022-Mar-03 at 10:49Actually this is the same issue as here.
The conditionalPanel
s are visible for a very short time when first invoking the app.
This causes a vertical scrollbar to appear and leads to the misalignment.
Use style = "display: none;"
to render the conditionalPanel
s hidden on startup (where needed) and please leave a thumbs up or other feedback here.
QUESTION
This is follows up on my June 30 post where I eliminated conditionalPanel
flashing in the sidebarPanel
when invoking the App. The solution was to move those sidebar conditional panels into renderUI
, eliminating flashing. However, I later found out that using renderUI
in this manner results in other limitations. Is there any way to eliminate invocation flashing without using renderUI
?
I include below 3 sets of code:
- Very short MWE code that illustrates the flashing issue, contributed by ismirsehregal
- Long, convoluted code that very clearly illustrates how all conditional panels flash by in sidepanel upon invocation, when sidebar conditional panels are rendered in UI (there is no
renderUI
for conditional panels in the sidebar panels like in #3 below which resolves this although it introduces other problems not explained in this post). - Adaptation of #2 above where
renderUI
is used and there is no invocation flashing.
I didn't want to completely strip down the code in items 2 and 3, so that the sidebar panels are large enough which makes the invocation flashing more obvious. Also I when I did some stripping down of this code I did lose some functionality like "Reset", which isn't relevant to the problem at hand in any case.
Though the code in #2 and #3 may be torturously long and involved, the moving of the conditional panel into renderUI
is straightforward.
No. 1 short MWE code:
...ANSWER
Answered 2021-Sep-13 at 19:59Rather use an observeEvent
within the server than conditionalPanel
in the ui as below (see #Added Code). I also needed to add an id to the h4()
and started out with all the second tab sidebar buttons hidden
upfront. Lastly I added ignoreInit = TRUE
to the observeEvent
as it's unnecessary initially:
QUESTION
I want to be able to update the selection available in the pickerInput based upon the selection made in the radio button input. In the example below, I want the radio button "A", to give a pickerInput list of mtcars$cyl, whilst a picker input of "B" to give a picker input of mtcars$mpg
I have tried doing this using if statements, but I haven't got anywhere so far. Reproducible example below:
...ANSWER
Answered 2022-Feb-26 at 12:09The server has to listen to the right UI Element (ID = "type" for the radio buttons in question). Currently it observes an undefined element "dist".
Try changing
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install shinyjs
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page