-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Add chart.responsiveResize(true) option to switch to viewBox resizing… #1312
Conversation
… instead of fixed width and height attributes
The implementation looks nice and clean. I'll need at least two tests
As I've noted, this is only one of many strategies for responsive resizing, so I'd prefer the name to have viewBox in in it somewhere. |
Thanks @atomless! |
@gordonwoodhull, good point. I'll change the option name to Can you offer any pointers on the tests, I normally use Ava for tests so am not familia with this style. I presume it should go in the base-mixin-spec? |
Yes, it should go in the base-mixin-spec. I know writing tests in an alien style is a burden; just do your best on that part. Checking whether an attr exists would be something like expect(chart.svg().attr('viewBox')).not.toBeNull(); Also, for future reference, it's best not to check in the artifacts when submitting a PR. This is easy for me to clean up, though. |
Okay. More specifically, in the base-mixin-spec, I can't locate a test for the width and height attr that normally gets added to the root svg and that the viewBox attr replaces if enabled. Seems the viewbox test should belong near that test or is there not one for that? |
Yup, looks like we don't check that attribute in particular. (We test Thematically, I'd guess this belongs after the "calculation of dimensions" test, since it's another method for responsive layout. |
Hi @atomless, I'm in the process of merging this for dc.js 2.1.7. I'm updating the examples in http://dc-js.github.io/dc.js/resizing/ so that we can test them by eye - please check it out once this is released. Just click on any of the examples and then add Currently it applies I haven't implemented the heatmap example because the screen is divided. Could do it with a little work. We can continue to refine this feature in 2.1.* as we get more experience with it. |
Released in 2.1.7 under the name It works pretty well. Thanks @atomless! |
SEO bump: try using this if you need a dc.js print stylesheet. |
… instead of fixed width and height attributes