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

add opt-in support for viewBox #135

Closed
wants to merge 5 commits into from

Conversation

davidjgoss
Copy link

@davidjgoss davidjgoss commented Feb 23, 2019

Fixes #97

Add support, without changing the default behaviour, to apply the width and height to the SVG via the viewBox attribute rather than width and height attributes. This is preferable when incorporating into responsive layouts, as it specifies the width and height merely as an aspect ratio and lets the SVG grow or shrink to any size depending on its containing element (and/or any CSS applied).

To use, you just call useViewBox on the created VennDiagram - it's a one-way setting:

var chart = venn.VennDiagram();
chart.useViewBox();
// draw with data

I added an alternate version of the "simple" example which uses this, and added screenshot tests for both with BackstopJS (sorry about all the boilerplate files!) which show the difference - you can run npm run backstop-check to see them.

@davidjgoss davidjgoss changed the title Feature/view box add opt-in support for viewBox Feb 23, 2019
@clintonmedbery
Copy link

@benfred ^

@clintonmedbery
Copy link

@davidjgoss is there a way to set min or max height/width with this? Thanks btw!

@davidjgoss
Copy link
Author

@clintonmedbery no, this just covers viewBox. For min/max height I would probably do that with .style (https://github.com/d3/d3-selection/blob/master/README.md#modifying-elements) or CSS

@JelleBlaauw
Copy link

Is this going to be merged anytime soon?

@davidjgoss davidjgoss closed this Dec 18, 2020
@davidjgoss davidjgoss deleted the feature/viewBox branch December 18, 2020 19:57
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.

Responsiveness
3 participants