Skip to content

plotly#554: crosstalk highlighting/linking works selectively #796

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

Closed
synikitin opened this issue Nov 15, 2016 · 6 comments
Closed

plotly#554: crosstalk highlighting/linking works selectively #796

synikitin opened this issue Nov 15, 2016 · 6 comments

Comments

@synikitin
Copy link

image

The plotly piece is ggplotly(p) %>% highlight(off = "plotly_unhover", color = "yellow").

I cannot give a reproducible example because the data is proprietary, and I do not really understand the issue to reproduce it with open data. The image has as much as I have. Little tinkering in a debugger shows that the issue seems to come up when hay.every is not an array when it should be one.

The issue emerges only for some number of data points. For sample size of 8, chart shows highlighting and brushed linking works across multiple charts, but with 9 points, neither work. Other combinations of points also work or do not work without an obvious pattern. This somehow has to be related to the for loop inside which hay.every is evaluated.

There also may be a connection to what R type determines the color of points. For the sample sizes that give an error, the issue goes away, at least for the number of points I tried, if I change from character to integer type.

@cpsievert
Copy link
Collaborator

Interesting. Can you provide the output of console.log(haystack);?

@cpsievert cpsievert reopened this Nov 16, 2016
@synikitin
Copy link
Author

The issue seems to be with findNestedMatches function. There is a type mismatch, sometimes the haystack argument is a string when it should be an array. The existing code only checks elements for being arrays - the for loop under the comment - but the whole container should be an array, too. So a simple fix, which I haven't tested a ton, is to add a type-checking statement like this:

function findNestedMatches(haystack, needleSet) {  
  var matches = [];  
  if(!Array.isArray(haystack)){  
    haystack = [haystack]; 
// ensure both haystack and needleset are an array of an arrays
  for (var i = 0; i < haystack.length; i++) {
    if (!Array.isArray(haystack[i])) {
      haystack[i] = [haystack[i]];
    }
  }
...
 } 

Note that I am only showing the initial lines of the function. I could do a pull request, but I am not sure about the branch.

cpsievert added a commit to jcheng5/plotly that referenced this issue Nov 16, 2016
@cpsievert
Copy link
Collaborator

@slavaua87 does this fix it? ^^^

@synikitin
Copy link
Author

No, same problem.

@cpsievert
Copy link
Collaborator

whoops, I made a silly mistake in f79cea9 -- does 2ec5bcc fix it?

@synikitin
Copy link
Author

Yes. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants