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

public api for custom multiline note #41

Closed
mipac opened this issue Sep 22, 2017 · 3 comments
Closed

public api for custom multiline note #41

mipac opened this issue Sep 22, 2017 · 3 comments

Comments

@mipac
Copy link

mipac commented Sep 22, 2017

It would be very useful to choose how the wrapping is done.

For example I found very useful to wrap based on the "\n" I insert in my label.
Using the wrap function:

var wrap = function wrap(text, width) {
        var lineHeight = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1.2;
        
            text.each(function () {
            var text = d3.select(this),
                words = text.text().split(/\n/).reverse().filter(function (w) {return w !== "";});

            var word,
                tspan = text.text(null);

            while (word = words.pop()) {
                tspan = text.append("tspan")
                    .style("text-anchor", "start")
                    .attr("x", 0)
                    .attr("dy", lineHeight + "em")
                    .text(word);
            }
        });

Perhaps could you expose a way to substitute the "warp" function or a "warp mode" for the existing one and some others like this, and some others...

Thank you for that cool lib :)

@susielu
Copy link
Owner

susielu commented Sep 26, 2017 via email

@susielu
Copy link
Owner

susielu commented Oct 9, 2017

This is available in v2.1.0 you can pass a wrapSplitter property to the note configuration for your own split settings. For example:

 { note: {
          label: " A different\n annotation type with long wrap",
          title: "Another title with a long wrap for testing",
          wrapSplitter: /\n/
        }
 }

In this case it would only wrap on the new line in the label. Thanks for this feature suggestion. Let me know if you have any issues with using it.

@susielu susielu closed this as completed Oct 9, 2017
@mipac
Copy link
Author

mipac commented Oct 9, 2017 via email

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

No branches or pull requests

2 participants