| ||
Chart Samples Style Examples SharpLeaf Tutorials Document Layout Tutorials Text Flow Tutorials Table Tutorials Visual Glossaries SharpPlot Reference SharpPlot Class SharpPlot Properties SharpPlot Methods SharpPlot Structures SharpPlot Enumerations PageMap Class SharpLeaf Reference SharpLeaf Class SharpLeaf Properties SharpLeaf Methods Table Class Table Properties Table Methods SharpLeaf Structures FontType Structure ParagraphStyle Structure BoxStyle Structure SharpLeaf Enumerations DocumentLayout Classes DocumentLayout Class PageLayout Class PageElement Abstract Class Frame : PageElement Class TextBlock : PageElement Class ImageBlock : PageElement Class Box : PageElement Class Rule : PageElement Class Common Reference Document Class VectorMath Class DbUtil Class Download Release Notes Licensing |
SharpPlot Tutorials > General Tutorials > Using Picture Formatters Using Picture FormattersYou may apply a ‘picture’ format to numeric values, and also to text labels to enforce truncation or wrapping into a given width. Formatting numeric valuesWherever you can use numeric value as labels (axes and data value tags) you may specify a suitable format string to have the numbers converted to appropriate text. Typical formats would be:
Note that .Net always shows leading minus signs for negative numbers. If you really want absolute values shown, use a 2-part format such as ‘##0;##0’ to have the negative values formatted without the leading minus. More formally... The characters ‘#’, ‘-’ and ‘0’ are used to place the digits. The total number of ‘-#0’ characters in front of the decimal point determines the largest number you can display. Larger numbers are shown as ‘****’ to indicate overflow. Leading ‘0’ characters are zero-filled; leading ‘#’ characters are suppressed if not used. Digits after the decimal point are always shown, so ‘#’ and ‘0’ are equivalent here. Negative numbers are given a leading ‘-’ only if you use ‘-’ rather than ‘#’ as the placeholder. The common currency symbols ‘$£’ and Euro will float to the front of the result if used as the first character in the format. The character ‘~’ suppresses the digit in that position, so a vector of years could be formatted as ‘~~00’ to suppress the century part of the 4-digit number. If the picture begins with an opening parenthesis, negative numbers will be parenthesised, rather than being shown with leading -ve symbols. If any of the tokens ‘E-0’ ‘E+0’ ‘E0’ occur in the formatter, scientific notation will be used. A ‘+’ in the exponent part will always be shown, but a minus will only be shown when necessary. Floating currency symbols and other leading and trailing characters may be used as normal, for example ‘-##0.00E+00kg’ is a valid formatter here. All special characters can be escaped with a preceding ‘\’ character, which must therefore be doubled to print out. All other characters are simply treated as insertions, with the exception of ‘,’ which is only inserted if there were enough digits in the number to require it. The trailing % does not automatically scale the data. Note that you always use the ‘American’ convention here for the decimal and thousands separators. These will be converted to your local currency symbols by the formatting function before the finished text is written to the chart. Formatting text labelsA limited subset of the picture formatting capability may be used with text items, such as value tags and axis labels.
These special characters may be escaped by preceding them with a backslash ‘\’. Any other characters are treated as insertions, so a format like ‘SKU:XX/XXXX’ could be used for product codes, or a format such as ‘XXXX-XX-XX’ would be appropriate for text dates in the form 20020612. You may use line-break character as an insertion within the string, for example ‘SKU:\nXX/XXXX’ will make 2-line labels prefixed with ‘SKU:’, and ‘SKU:\nXXXXXX;’ will make a multi-line label wrapping at 6 X-widths in the label font size. See also ...SharpPlot.XLabelFormat Property | SharpPlot.YLabelFormat Property |