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

Please provide more usage examples #2

Closed
goodforenergy opened this issue Feb 2, 2016 · 5 comments
Closed

Please provide more usage examples #2

goodforenergy opened this issue Feb 2, 2016 · 5 comments
Assignees
Labels

Comments

@goodforenergy
Copy link

Hey!

I'm trying to swap my code from using the text-wrapping utility in d3plus to this module, but I'm struggling to understand how I'm supposed to use it. I'd be happy to contribute some docs once I get my head around it.

My current code has some circular nodes which have data associated with them. This is how I insert the labels:

nodeData
    .append('text')
    .text(function(node) {
        return node.name;
    })
    .each(function() {
        d3plus.textwrap()
            .container(d3.select(this))
            .shape('circle')
            .draw();
    });

How would I convert this to using d3plus-text? I have managed to get the box method to insert tspans into the page based on the data I give it (by passing through the full node data array at once), but I want to wrap text that is associated with individual nodes on my page (the nodeData array).

Thanks in advance,

Helen

@davelandry
Copy link
Member

I'm using this module in the new d3plus-shape module. Take a look at these lines for an example enter/update/exit: https://github.com/d3plus/d3plus-shape/blob/master/src/rect.js#L104-L166

The biggest change is that the container element for the new d3plus-text module should be either an <svg> or <g> element (and not a <text> tag). The module itself handles creating the <text> tag along with all of the <tspan> lines.

@goodforenergy
Copy link
Author

Thanks @davelandry. I'm not sure this module is exactly what I'm looking for. The two features I'm making use of from the full D3Plus library at the moment are:

  • text-wrapping within a circle (i.e knowing that the width at which text should wrap changes as the y placement of the text changes)
  • automatic detection of container bounds (so I don't have to calculate those widths myself)

Here's a simple example demonstrating how I'm currently using the library.

I tried to replicate this example using this module, which you can see here.

Am I correct in presuming that to finish this example I would need to calculate the width of the circle myself for each line of text? Or am I missing something?

@davelandry
Copy link
Member

This module isn't currently as fully functional as the text wrapping from the main library, but those are both features we want to incorporate. I've created specific issues for those features. Don't be shy in creating new issues 😉

@goodforenergy
Copy link
Author

Got it. Thanks @davelandry :)

@davelandry
Copy link
Member

davelandry commented Jul 20, 2016

Big update today. Renamed some functions and updated the README with 2 examples: one is a generic getting started and another one shows the resize function.

Are there any other specific questions/features that anyone would like to see documented at this time? I will keep this issue open as long as there are requested examples.

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

No branches or pull requests

2 participants