Comments (6)
colour
In terms of colour, see #25 and let me know if you need any more help. I hope to get this better documented soon.
event handling
Also poorly documented, but I dispatch mouseover/mouseout
and click
with an array representing the path, so these can be accessed. I will include a quick example below. For a shiny example, see ?sunburstR::add_shiny
.
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
from sunburstr.
@NovasTaylor this http://timelyportfolio.github.io/sunburstR/example_baseball.html contains another example of event handling
from sunburstr.
Hello, @timelyportfolio , in the example you gave above,
this.instance.chart.on('click',function(d){
alert(d);
})
If we want to direct to a url, would open.window statement work?
Another question is: for the above link, http://timelyportfolio.github.io/sunburstR/example_baseball.html,
I copied the code under title "Use sunburst event" to Rstudio, which doesn't give me the link for the hovered path. Do you have any idea about it? I appreciate your help.
Selina
from sunburstr.
window.open
on.click
Yes, that should work fine, but you will need to generate the url unless it has been added in the data
of the node. You could use a reference table or build it up as in lines. I know I have another non-sunburst example somewhere, but I could not find it. If you have trouble, post some code and I'll try to help.
use sunburst event error
I am not sure, since this still works for me. If you are not in rmarkdown
, you will need to wrap the tagList
with browsable
or pipe tagList() %>% browsable()
.
browsable(
tagList(
sb,
tags$div(id="games", style="margin-top:100px"),
tags$script(HTML(
sprintf(
'
var action = %s;
function mouseovered(d){
var games = action.filter(function(evt){
return evt.event === d.join("-");
});
var div = document.getElementById("games");
div.innerHTML = games.map(function(game){
return [
"<a href=\'http://gd2.mlb.com/components/game/mlb/year_2016/month_08/day_25/",
game.gameday_link,
"\'>",
game.gameday_link,
"</a><br/>"
].join("");
}).join("\\n");
}
',
jsonlite::toJSON(action, auto_unbox=TRUE, dataframe="row")
)
))
)
)
from sunburstr.
Thanks, @timelyportfolio
For the example you showed me above, instead of Mouseover event, I want to have Click event on Sunburst chart to redirect me to a URL, I am trying to code as following:
sb$x$tasks <- list(htmlwidgets::JS(
'
function(){
this.instance.chart.on("click",clicked);
function clicked(d){
var games = action.filter(function(evt){
return evt.event === d.join("-");
});
window.open(games.map(function(){
return [
"<a href='http://gd2.mlb.com/components/game/mlb/year_2016/month_08/day_25/",
"'>",
"</a><br/>"
]
})
);
}
}
'
))
But this doesn't give me the click, so could you help me take a look?
Many thanks to your help!
Selina
from sunburstr.
I think this is "solved". Please reopen if not. Thanks for the issue.
from sunburstr.
Related Issues (20)
- sund2b rootLabel malfunction when tooltip option used HOT 2
- no output HOT 4
- sunburst d2b & d3tree treemap fail to render together in shiny HOT 3
- Export sunburst plot as static vector image
- Have the legend open by default HOT 1
- Sizing problems of sund2b output in shiny window or browser with fluidPage HOT 2
- Radial color gradients within arcs HOT 3
- csv_to_hier not working as expected when only one element is spitted out by str_split HOT 18
- Sunburst function examples all fail "Error: Argument 1 must have names" HOT 6
- legend font HOT 1
- crosstalk support HOT 5
- sund2b - display root label on top, centered, and horizontal?
- Solution for manually coloring each leaf? HOT 7
- sunburst example is not working HOT 3
- rootLabel in sund2b is not working HOT 1
- warning when using sunburstOutput with shiny 1.7.4 (latest CRAN) HOT 3
- sunburst plot is rounding when it shouldn't v2.1.8 HOT 3
- custom sund2bBreadcrumb outputs text in all upper case HOT 1
- Modify sund2b breadcrumb size HOT 2
- Error when exporting HTML-plot
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sunburstr.