question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Best way to achieve multiline text in titles (tspans)

See original GitHub issue

I noticed from reading the code that title text is split into tspan elements, when an array of strings is provided. Nice! I also noticed legends have the same feature. I guess the docs should be updated for these:

https://apexcharts.com/docs/options/xaxis/ https://apexcharts.com/docs/options/title/ https://apexcharts.com/docs/options/legend/

Anyway, I was trying to achieve multiline text and wondered what would be the ideal way. Just fiddling in the browser dev tools I managed to get the tspans below each other and roughly centered with some quite awkward parameters:

<text id="SvgjsText1120" font-family="Helvetica, Arial, sans-serif" x="77.5" y="359" text-anchor="middle" dominate-baseline="central" font-size="1rem" fill="#373d3f" class="apexcharts-xaxis-title-text " style="font-family: Helvetica, Arial, sans-serif;">
    <tspan id="SvgjsTspan1121" dx="-30">Bla blabla bla blablabla bla bla.</tspan>
    <tspan id="SvgjsTspan1122" dy="24" dx="-240">Blu blublublu blu blublublub blu blubl.</tspan>
</text>

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
junedchhipacommented, Jan 12, 2020

SVG.js has built-in support for creating multiline texts with tspan. I will see how feasible it is to convert current text into a multiline by using those the newLine() method of svg.js. https://svgjs.com/docs/2.7/elements/#svg-text

0reactions
junedchhipacommented, Jan 3, 2020

Yeah, the work is under progress. Here’s a sneak peek.

Screen Shot 2020-01-04 at 12 34 42 AM

It will be finished in a couple of days.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SVG Multiline Text with tspan - Jarrett Meyer
The easiest solution is to break the lines into independent tspan elements. We want to produce an output that looks like this. <svg...
Read more >
Chapter 4. Multiline SVG Text - O'Reilly
This chapter discusses the basic attributes to position spans of text, showing how you can move the virtual typewriter to a new point...
Read more >
<tspan> - SVG: Scalable Vector Graphics - MDN Web Docs
The SVG element defines a subtext within a element or another element. It allows for adjustment of the style and/or position of that...
Read more >
How to create multi-line <h1> - DEV Community ‍ ‍
The challenge. Alt Text. Forget about the gray paragraph and focus on the title. You can see that it spans over two lines...
Read more >
Align lines of text to center in SVG - Stack Overflow
I can align the text in each individual <tspan> by adding text-anchor="middle" to it. But how to do relative centric alignment of those...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found