Skip to content
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

Fix/legend resize #356

Closed

Conversation

timelyportfolio
Copy link
Contributor

This is my first attempt at addressing #348 and plotly/plotly.R#525. In summary, I

  • moved some code out of the if(firstRender==true block as suggested in @etpinard issue comment
  • fixed clipPath enter,append,exit pattern to update on resize
  • added scrollheight argument to the scrollHandler and remove eventListeners on resize to avoid scope problems
  • changed drag behavior to d3.behavior.drag() which should properly handle touch and allow to work properly in RStudio viewer

Since this is my first pull, I apologize if I missed any of the contribution guidelines. Also, other than a visual test, I was not sure how to test. I would appreciate some advice here.

@timelyportfolio
Copy link
Contributor Author

mistake 1 forgot to lint. doing now.


var scrollBarTrack = scrollheight - constants.scrollBarHeight - 2 * constants.scrollBarMargin,
translateY = scrollBox.attr('data-scroll'),
scrollBoxY = Lib.constrain(translateY - delta, Math.min(scrollheight - opts.height, 0), 0),
scrollBoxY = Lib.constrain(translateY - delta, scrollheight-opts.height, 0),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐄 spacing between scrollheight and opts.height.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh thanks. should have thought about using d3 wheel also. great change!

@mdtusz
Copy link
Contributor

mdtusz commented Mar 24, 2016

This looks pretty good to me. We'll wait for the all-clear from @etpinard then merge it in!

@etpinard
Copy link
Contributor

Yep. I like this. I was worried about using d3 events looking forward to d3's 4.0 release. But looks like events on selection will be part of the stock d3-selection package, which we'll obviously need. So 🍻 great solution!

@timelyportfolio Can you add a test case in legend_scroll_test.js similar to this case? Your test case should feature a call to Plotly.relayout with a layout height/width update to check that the legend dimensions update properly and that only one handler of each type is attached to the legend nodes.

@etpinard
Copy link
Contributor

It would be nice to merge this one in for the 1.7.1 release at some point this week.

@timelyportfolio, are you going to have time to work on adding a test case in the next few days?

@timelyportfolio
Copy link
Contributor Author

@etpinard I should be able to wrap this up today.

@etpinard
Copy link
Contributor

Great.

@timelyportfolio can you also check that this example works as expected? Thanks!

@timelyportfolio
Copy link
Contributor Author

@etpinard yes, will be happy to check this also

@timelyportfolio timelyportfolio force-pushed the fix/legend-resize branch 3 times, most recently from c012d74 to 43d430c Compare March 29, 2016 21:22

// clippath resized to new height less than new plot height
expect(+legendHeight).toBe(getPlotHeight(gd));
expect(+legendHeight).toBeLessThan(+origLegendHeight);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you check against the computed height using toBeCloseTo?

It helps catch potential bugs earlier than just relative size comparison.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, will be happy to; sorry for the flurry of commits; my local set up broke this morning.

@timelyportfolio timelyportfolio force-pushed the fix/legend-resize branch 7 times, most recently from a565dc6 to 3e6b949 Compare March 30, 2016 03:00
@timelyportfolio
Copy link
Contributor Author

I'm having a very difficult time debugging these simple tests with testing broken on my devel machine. I don't want to hold up the 1.7.1 release. Please let me know if you can help me see the obvious that I am missing. Thanks. Will try again tomorrow.

@etpinard
Copy link
Contributor

@timelyportfolio I pulled down your branch on added a test fixup commit in #365.

This issue is now a week old, and quite a few users have noticed its effects, so I decided to get your patch in ASAP. Thanks for work 🍻

@etpinard etpinard closed this Mar 30, 2016
@timelyportfolio
Copy link
Contributor Author

thanks!

@timelyportfolio timelyportfolio deleted the fix/legend-resize branch March 30, 2016 14:51
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

Successfully merging this pull request may close these issues.

3 participants