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

Word Wrap for Labels #80

Open
hisenberg1 opened this issue Sep 5, 2017 · 1 comment
Open

Word Wrap for Labels #80

hisenberg1 opened this issue Sep 5, 2017 · 1 comment

Comments

@hisenberg1
Copy link

Is there a way to have the labels automatically word wrap when the funnel is either large (wider) or smaller (narrower) so that the labels stay within the funnel?

@jakezatecky
Copy link
Owner

jakezatecky commented Sep 5, 2017

This is not supported, yet. It's a bit non-trivial because SVG text elements require very specific calculations and word-wrapping is not natively supported. The library would have to manually force newlines if the width would necessitate it.

As shown in the examples, you can override label.format to inject newline characters to force manual wrapping between the label and value yourself. You can also add newlines to the individual labels if necessary:

const data = [
    { label: 'Inquiries', value: 5000 },
    { label: 'Applicants', value: 2500 },
    { label: 'Admits', value: 500 },
    { label: 'My Long\nDeposits Label', value: 200 },
];
const options = {
    label: {
        format: '{l}\n{f}',
    },
};

const chart = new D3Funnel('#funnel');
chart.draw(data, options);

As far as the D3Funnel library handling this, it is not on the immediate horizon.

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