Skip to content

Best way to achieve multiline text in titles (tspans) #388

@mestaritonttu

Description

@mestaritonttu

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>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions