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

How to: line breaks in label #38

Closed
meliborn opened this issue Oct 25, 2015 · 3 comments
Closed

How to: line breaks in label #38

meliborn opened this issue Oct 25, 2015 · 3 comments

Comments

@meliborn
Copy link

I have the next issue:

How to make labels more responsive?

@jakezatecky
Copy link
Owner

Admittedly, there is unfortunately no current way to move the labels anywhere (#10), wrap them, or add line breaks. It is rather non-trivial to add these elements, but certainly desirable.

@jakezatecky
Copy link
Owner

Upon further inspection, it appears like it would be relatively easy to support manually-defined line breaks. Would just need to add appropriate <tspan> elements. Just need to make sure that the first element has a dy of (-1 * textHeight * (length - 1)) / 2 while the rest of the <tspan> elements have a dy of textHeight.

<text x="160" y="280" fill="#fff" text-anchor="middle" dominant-baseline="middle" pointer-events="none" style="font-size: 14px;">
  <tspan dy="-10" x="160" text-anchor="middle" dominant-baseline="middle">Applicants</tspan>
  <tspan dy="20" x="160" text-anchor="middle" dominant-baseline="middle">12,000</tspan>
</text>

I'll target this for a release soon.

@jakezatecky jakezatecky added this to the Release 0.7.x milestone May 19, 2016
@jakezatecky
Copy link
Owner

Line breaks are now supported in the label.format. It is important to note that this is not done responsively: the chart will not automatically break lines when it the text will exceed the container.

Since this is a change from previous treatment of newline characters, this will be released in a new major version.

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