New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have legend on as a default? #15

Open
MarkEdmondson1234 opened this Issue May 19, 2016 · 13 comments

Comments

Projects
None yet
6 participants
@MarkEdmondson1234

MarkEdmondson1234 commented May 19, 2016

Is it possible to not have to click to see the legend?

edit: in light of "time != money" which I agree with completly given my year old daughter ;) I'm happy to help with coding it if you point me in the right direction and think it possible. I've used sunburstR for a while for web analytics multi-touch analysis and it rocks.

@timelyportfolio

This comment has been minimized.

Owner

timelyportfolio commented May 19, 2016

An ugly hack to accomplish this using onRender:

# devtools::install_github("timelyportfolio/sunburstR")

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=F
  ,stringsAsFactors = FALSE
)

sunburst(sequences)

# with new htmlwidgets, we get onRender
htmlwidgets::onRender(
  sunburst(sequences),
"
function(el,x){
  // check legend
  d3.select(el).select('.sunburst-togglelegend').property('checked',true);
  // simulate click
  d3.select(el).select('.sunburst-togglelegend').on('click')();
}
"
)

I am trying to think through how best to provide this as an option for sunburstR on the R side.

I'd love your help testing #13 and #14. The new behavior is default now if you install the newest from Github.

@timelyportfolio

This comment has been minimized.

Owner

timelyportfolio commented May 19, 2016

@MarkEdmondson1234 in terms of time != money, parcoords and sunburstR are the clear winners in popularity based on blog views, so I plan to focus on these. I will probably target a CRAN release in the next couple of months.

@voxnonecho voxnonecho referenced this issue Aug 17, 2016

Closed

CRAN-bound #22

@vrybkin

This comment has been minimized.

vrybkin commented Nov 14, 2017

Hi Kent,

Just so you know, I think upgrading to 1.0.2 made this hack stop working, and the default behavior seems to still not be having the legend turned on.

Many thanks!

@timelyportfolio

This comment has been minimized.

Owner

timelyportfolio commented Nov 14, 2017

Interesting, I will check to see what might be happening. Thanks for the report.

@cjyetman

This comment has been minimized.

Collaborator

cjyetman commented Nov 20, 2017

I'm pretty sure this hack broke because d3 is no longer added to the global namespace. You can work around that by using the withD3 = TRUE parameter.

library(sunburstR)
library(htmlwidgets)

sequences <- read.csv(
    system.file("examples/visit-sequences.csv",package="sunburstR")
    ,header=F
    ,stringsAsFactors = FALSE
)

htmlwidgets::onRender(
    sunburst(sequences, withD3 = T),
    "
    function(el,x){
    // check legend
    d3.select(el).select('.sunburst-togglelegend').property('checked',true);
    // simulate click
    d3.select(el).select('.sunburst-togglelegend').on('click')();
    }
    "
)
@timelyportfolio

This comment has been minimized.

Owner

timelyportfolio commented Nov 20, 2017

Thanks again @cjyetman. @vrybkin, I think this will solve the problem. Please let us know if it does not.

@vrybkin

This comment has been minimized.

vrybkin commented Nov 21, 2017

Thank you for your replies, @timelyportfolio and @cjyetman!

Your proposed change does work on render. However, suppose that I have my sunburst plot attached to a data set dependent on reactivity. When the data set changes, the legend functionality flip-flops after the sunburst is re-rendered, i.e. to turn the legend on, you have to uncheck the legend box, and to turn the legend off, you have to check the legend box. I think this quirk is fine, but just letting you know.

Many thanks for your help!

@cjyetman

This comment has been minimized.

Collaborator

cjyetman commented Nov 21, 2017

This may be a better way to do it...

library(sunburstR)
library(htmlwidgets)

sequences <- read.csv(
    system.file("examples/visit-sequences.csv",package="sunburstR")
    ,header=F
    ,stringsAsFactors = FALSE
)

htmlwidgets::onRender(
    sunburst(sequences, withD3 = T),
    "
    function(el,x){
    d3.select(el).select('.sunburst-togglelegend').property('checked', true);
    d3.select(el).select('.sunburst-legend').style('visibility', '');
    }
    "
)
@vrybkin

This comment has been minimized.

vrybkin commented Nov 27, 2017

Thanks, @cjyetman - this works like a charm!

@mirzaabidpp

This comment has been minimized.

mirzaabidpp commented Nov 28, 2017

Hi!,
I am new to sunburst i tried to follow above instructions but unable to on legends. Would you please help me to resolve this issue? I am interested to label each section with their name @cjyetman attached is my file.
Waiting for your prompt response.

Abid

m1c

@cjyetman

This comment has been minimized.

Collaborator

cjyetman commented Nov 28, 2017

@mirzaabidpp you'd probably be better served on Stack Overflow for questions like that. GitHub issues are used for reporting bugs and feature requests. Also, there is no file attached.

@mmc00

This comment has been minimized.

mmc00 commented Jan 7, 2018

Is there any option to remove the word "Legend", or Change it?

@cjyetman

This comment has been minimized.

Collaborator

cjyetman commented Jan 7, 2018

@mmc00 As I said in the previous comment, GitHub issues are typically used for reporting bugs and feature requests rather than support requests, and each issue is about a precise thing, so asking additional questions that go beyond the original topic is not very helpful or productive.

That being said, you could add the following JavaScript to the example above to change the "Legend" text...

document.getElementsByClassName('sunburst-sidebar')[0].childNodes[2].nodeValue = '';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment