Is there a way to force line-breaks to titles and subtitles set using the setTitle() and setSubtitle() methods of Chart configurations? The titles understand some HTML tags (at least and ), but
does nothing.
Hello,
you need to use setUseHTML method to enable html in the title.
Configuration conf = chart.getConfiguration();
Title chartTitle =new Title("Historic World Population <br> by Region");
chartTitle.setUseHTML(true); conf.setTitle(chartTitle);
Subtitle subtitle = new Subtitle("Source:<br> some source");
subtitle.setUseHTML(true);
conf.setSubTitle(subtitle);
Thanks dmitrii, apparently this feature has been added in Charts 3.0.0. Will just need to update from 2.1.3 in near future.
Hi Niko,
Until you update to Charts 3 one alternative is to use “
”
Configuration conf = chart.getConfiguration();
conf.setTitle("Test <br/> multiple <br/> lines");
Title and Subtitle will handle correctly the following tags: , , , ,
, . Spans can be styled with a style attribute, but only text-related CSS that is shared with SVG is handled.
Hope this helps
Also https://vaadin.com/docs/-/part/charts/java-api/charts-migration.html this one can help you to migrate.
Thanks a lot, I will look into the migration guide when I get a chance!
I assume the working HTML tag list Guillermo posted is up somewhere, but for the life of me I couldn’t find it from the documentation.
For some reason,
is the only variant of line break tag that isn’t working with Charts, I was stupid not to try the other positions for /.