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

advanced overflow options #1

Open
Hypercubed opened this issue Jan 25, 2016 · 4 comments
Open

advanced overflow options #1

Hypercubed opened this issue Jan 25, 2016 · 4 comments

Comments

@Hypercubed
Copy link

Thank you for making this a standalone module. It took me some time to figure out the new API so perhaps I am missing something.

What I am seeing is that if a word is too long for the bounding box it is omitted completely. I believe this is happening here: https://github.com/d3plus/d3plus-text/blob/master/src/box.js#L189 . If I comment out this line the labels that are too long for the bounding box overflow. Not sure if this is by design, perhaps it should be an option at least.

I'm using the module like this:

      const box = d3plusText.box()
        .textAnchor('middle')
        .fontSize(14)
        .width(d => d.values.length * boxWidth + 5)
        .text(d => d.key.replace(/_/g, ' '))
        .height(45);

      subplot.append('g')
        .attr('class', 'boxLabelText')
        .attr('transform', 'translate(-5,0)')
        .each(function (d) {
          box
            .data([d])
            .select(this)();
        });
@davelandry
Copy link
Member

That was the intended behavior. I've always just enabled the fontResize and this took care of shrinking the text to fit.

That being said, I have no problem adding in a "overflow" boolean.

@davelandry davelandry self-assigned this Jan 25, 2016
@davelandry davelandry changed the title If a word exceeds box width text is not shown... allow text to overflow box when too long to fit Jan 25, 2016
@Hypercubed
Copy link
Author

I was going to do a PR but see it is already done. Have you considered instead of just a boolean, add a few options like 'clip', 'resize', 'hidden', 'overflow'?

@davelandry
Copy link
Member

hmm interesting, can you describe the difference between "clip" and "hidden", and how "resize" differs from the fontResize method?

definitely wouldn't mind you taking a crack at it if you feel comfortable

@davelandry davelandry reopened this Jan 26, 2016
@davelandry davelandry removed their assignment Jan 26, 2016
@davelandry davelandry changed the title allow text to overflow box when too long to fit advanced overflow options Jan 26, 2016
@Hypercubed
Copy link
Author

My idea was the following:

'hidden' - hide the entire text that overflows, this is the current default. I guess this name can be easily confused with clip.

'visible' - just show it.

'clip' - draw a binding box (defined a clip path?) and hide the overflow.

'resize' - force resize when text overflows. I realized later this is the same as setting fontMin === font Size.

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

No branches or pull requests

2 participants