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

Try out visibility:inherit default for text #990

Merged
merged 2 commits into from
Oct 12, 2016
Merged

Conversation

rreusser
Copy link
Contributor

@rreusser rreusser commented Sep 29, 2016

See #984

The goal of this PR is to get circle-ci to see what happens if the visibility default on text is visibility: inherit instead of visibility: visible. visible hard-codes it and is difficult to override. I had an ominous feeling about this change leading to a rabbit hole of related fixes and compensations, but let's see what happens…

@etpinard etpinard added bug something broken status: reviewable labels Sep 29, 2016
@etpinard etpinard added this to the v1.18.0 milestone Sep 29, 2016
@@ -91,7 +91,7 @@ exports.convertToTspans = function(_context, _callback) {
}
_context.text('')
.style({
visibility: 'visible',
visibility: 'inherit',
Copy link
Contributor

Choose a reason for hiding this comment

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

This is definitively the first step to take. 👍

My only concern here is possible incompatibilities in Illustrator and svg conversion tools (e.g. Batik).

To avoid any rolling 🎲 , I'm thinking about adding a few lines to the toSVG routine making sure all exported images get visibility: 'visible' as opposed to inherit while interactive graphs would get 'inherit'.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good to know about. That's the sort of obscure possibility for interaction that I thought maybe could exist.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Feel free to pull this fix wherever you need or redo it elsewhere. I won't worry further about it.

 with *visibility: inherit* on SVG export
Copy link
Contributor Author

@rreusser rreusser left a comment

Choose a reason for hiding this comment

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

This all looks good to me. I assume tspans never have visibility set. I'm also assuming that there aren't other corner cases or obscure features that would cause potential issues.

var txt = d3.select(this);

// hidden text is pre-formatting mathjax,
// the browser ignores it but it can still confuse batik
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This seems to make sense 👍

if(txt.style('visibility') === 'hidden') {
txt.remove();
return;
}
else {
// force other visibility value to export as visible
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This also makes sense. Presumably it overwrites visibility: inherit (or anything that's not hidden, for that matter), with visible. Which seems correct.

textElements = svgDOM.getElementsByTagName('text');

for(var i = 0; i < textElements.length; i++) {
expect(textElements[i].style.visibility).toEqual('visible');
Copy link
Contributor Author

@rreusser rreusser Oct 12, 2016

Choose a reason for hiding this comment

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

Good check. 👍

@rreusser
Copy link
Contributor Author

Kinda transferred ownership of this PR. Feel free to merge if you're content, otherwise let me know if further action is required.

@etpinard etpinard merged commit f7a8afa into master Oct 12, 2016
@etpinard etpinard deleted the visibility-inherit branch October 12, 2016 18:31
@fresheneesz
Copy link

Thanks!

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

Successfully merging this pull request may close these issues.

3 participants