leveraging JavaScript's alert function (D3r) for transmitting data to R

How can I transfer data from a Sunburst plot to R on the server side? The code provided below generates a sunburst plot and displays an alert when a specific level is selected. I want to be able to pass this information so that I can create a download list.

library(sunburstR)

# read in sample visit-sequences.csv data provided in source
#   https://gist.github.com/kerryrodden/7090426#file-visit-sequences-csv
sequences <- read.csv(
  system.file("examples/visit-sequences.csv",package="sunburstR")
  ,header = FALSE
  ,stringsAsFactors = FALSE
)

sb <- sunburst(sequences)

sb$x$tasks <- list(
  htmlwidgets::JS(
"
function(){
  //debugger;

  this.instance.chart.on('click',function(d){
    alert(d);
  });
}
"    
  )
)

sb

Answer №1

try this method:

this.example.chart.onclick = function(data){
    Shiny.setInputValue("info", data);
};

afterwards you can access the value using:

input$info

on the server side, retrieving the value of data.

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

Boost Engagement with the jQuery PHP MySQL Like Feature

Seeking assistance in creating a like button with PHP, MySQL, and jQuery. I'm encountering an error but unable to pinpoint its source. Can anyone provide guidance? The project involves two pages: index.php & callback.php INDEX $k = 1; //POST ID $n ...

How to avoid an additional carriage return in Internet Explorer when editing a Textarea?

In Internet Explorer, we are facing an issue with a multiline textarea. After setting the content using JavaScript and checking it, everything appears correct without any additional carriage returns in the textarea: document.getElementById( 'text-ar ...

Error with infiniteCarousel in Internet Explorer versions 7 and 8 when using jQuery

Hello everyone! I've run into a little issue with some jQuery code I'm using. It was working fine before, but after making several changes and improvements, I can't seem to figure out what the problem is. I keep getting JS errors in both IE7 ...

What is the best way to ensure that the operations are not completed until they finish their work using RX

Is there a way to make RXJS wait until it finishes its work? Here is the function I am using: getLastOrderBeta() { return this.db.list(`Ring/${localStorage.getItem('localstorage')}`, { query: { equalTo: fa ...

Converting a text area into a file and saving it as a draft in the cloud with the

Can content from a text area be converted into a file of any chosen format and saved in the cloud? Additionally, should every modification made in the text area automatically update the corresponding file stored in the cloud? ...

Rearrange an irregular matrix using JavaScript

I have a matrix that can vary in width depending on the results received from the server. Here is an example: [undefined, undefined] [1, 2, 3, 4] [1, 2] [undefined, undefined, undefined] [1, 2, 3, 4, 5, 6] My goal is to transform it into this format: [u ...

Choosing particular contenteditable divisions using jQuery

Consider the following HTML structure for a specific type of blog post editor: <div class="entry"> <div class="title" contenteditable="true"> <h2>Title goes here</h2> </div> <div class="content" contenteditable ...

Using jQuery to access the ID of a div and create a custom close button

I am trying to implement a close button for my popup DIVs. Each one has a unique ID and I want to hide them by setting the CSS 'display' property to 'none' when closed. However, the following example is not functioning as expected. I a ...

Utilizing jQuery's fadeIn() and fadeOut() functions can lead to a significant decrease

I recently added a loading indicator in the form of an animated .svg with fadeIn and fadeOut effects to display it on my webpage alongside an animated canvas. However, I noticed a significant decrease in the performance of my canvas during these operations ...

comprehending the concept of express and mastering its usage

Can you confirm if my understanding is correct? 1) So, when I write this line of code... const express = require(“express”) I am assigning a "Class" to the variable express. 2) And then, when I call this function... express.jason() Am I correctly ...

Combining Various Time Periods in JavaScript

After encountering various old solutions, most utilizing jQuery, for adding multiple durations together, I decided to create my own script below. While I may not be a JS expert, I am open to input on any potential issues with this code or a more efficient ...

Using jasmine-node to create a spy on a constructor invoked within another function

As a beginner in Jasmine, I am looking to write unit tests for a node.js application using this framework. However, I am facing some challenges, one of which is described below: var sampleFunction = function(){ var loader = new Loader(params); // ...

What is the reasoning behind adonis labeling it as "incorrect (without strata)"?

Learning how to use PERMANOVA has definitely been a challenge for me, especially when starting from scratch with the example provided. The code snippet below is taken directly from the help page in adonis. While I can follow along with the example, I' ...

What causes the variable to be invisible in the imported file?

Within the main.js file, there is a specific code snippet: var test_mysql = require('./test_mysql.js') ... //additional code before(function(){ test_mysql.preparingDB(test_mysql.SQL_query.clear_data); // or test_mysql.preparingDB(SQL ...

AWS Lambda, where the billing time exceeds the actual processing time

While working on my Lambda function in Node.js, I noticed a significant difference in the time measured from the start to the end of the function compared to the billed duration provided by Lambda. The function itself takes around 1400 milliseconds to exec ...

Attempting to modify the Nivo slider configuration has proven to be ineffective

Can someone assist me in getting the Nivo Slider to function properly? I keep receiving a "syntax error" on the last line and can't seem to figure out what's causing it. The error occurs specifically on the line that reads: " }); " which is the ...

Data connections in React Firebase provide essential links between multiple pieces of information

In my React application, there is an Administration area where the Admin user can add items to a large catalog stored in Firebase under "catalogue". When a regular user logs into their account, they can see the list of items added by the Admin and choose ...

Customize the header toolbar title in FullCalendar

I am using a basic fullcalendar with buttons in the headerToolbar My question is, how do I customize the titles on these buttons? https://i.sstatic.net/xAgXG.png https://i.sstatic.net/wK5IX.png For example, instead of month view I'd like it to be j ...

Rails 5 Bootstrap 3 Challenge: Unresolved Application-Wide Modal Glitch

Setting up modals for the new and edit actions in my users controller was simple, but now I want to ensure display consistency by having the user show page also appear in a modal. Currently, users access their show page through the link: <li><%= ...

Examining the interaction effect in a structural equation modeling (SEM) with observable variables using R

In my current research project, I am working on estimating a Structural Equation Model (SEM) with observed variables. To handle missing data, I have decided to use Full Information Maximum Likelihood (FIML) within the SEM framework. One interesting aspect ...