Reference > Glossaries > Formatting text with simple HTML tags

Formatting text with simple HTML tags

SharpPlot allows a limited subset of HTML tags to be included in all text elements, typically headings or axis labels.

The tags which may be used in all output formats are:

<b> – to bold a section of text
<i> – to italicise a section of text
<u> – to underline a section of text
<sup> – to superscript a section of text
<sub> – to subscript a section of text
<code> – to set a section of text in Courier (fixed pitch)
<strike> – to strike through a section of text (not supported in XAML)

For example:

sp.Heading = "Data for Current Year<sup>1</sup> for <b>all</b> Products";

This will format the text in the main chart heading, which may refer to Note-1 elsewhere in the output.

Note that you can use these HTML tags in text formatting strings, for example:

    sp.LabelLineSpacing = 1.4;
    sp.XDateFormat = "MMM\nyyyy";
    sp.XLabelFormat = "X~~X<b>XXXX</b>";

This can be used with Spanned labelling to generate monthly labels (with the first letter of the month name) and a bolded year centred under the available months.

Charts saved as VML

In this one case, you can use any HTML tags in your text, as they are simply passed directly into the output. However please be aware that SharpPlot will not measure text correctly if you use the <font> tag to change the text size, and as a result captions and Y-Labels may not wrap correctly.

For output saved as VML, SVG PDF or XAML, you may include hyperlink references in the text. For PDF and the various raster formats, superscripts and subscripts will not be underlined even if an underlined font is used in the main text. This improves the appearance of footnote references.


Send comments on this topic
© Dyalog Ltd 2013