For AI agents: the complete documentation index is available at https://docs.dataplatform.ovh.net/llms.txt, the full documentation bundle is available at https://docs.dataplatform.ovh.net/llms-full.txt, and this page is available as Markdown at https://docs.dataplatform.ovh.net/sdk/app-formatter.md.
  • 🇬🇧 English
  • Formatters

    Warning

    Rework pending, no delivery date. The Front App SDK (ReactJS) and the Front API SDK (NodeJS) are both being replaced. This page documents the current release, remains accurate, and is maintained until the replacement ships. Code written against it keeps working.

    Formatters are used to format the data of your application so they display correctly, with units and separators for example.

    This configuration will go into the ./config/formatter.json configuration file loaded from ./config/global.json.


    Formatters list

    separator

    Description: Allows you to choose the separators of thousands and decimals.

    OptionDescriptionTypeValues
    thousandThousand separatorstring-
    decimalDecimal separatorstring-

    Example:

    {
        "separator": {
            "thousand": ",",
            "decimal": "."
        }
    }

    measures

    Description: Allows you to format a number with a suffix.

    OptionDescriptionTypeValues
    unit Unit suffixed to the value of the datastring-
    roundThe rounding of the data (ignored if short is not empty)number-
    multMultiplication of the data by the provided valuenumber-
    powsList of unit prefixes to applied at every threshold (1, 103, 106, 109, ...)array-
    shortNumber of digits displayed, will be used by "pows" to determine which prefix to applynumber-

    Example:

    In the following example, turnover is the data to be formatted. The configuration can be read as follows:

    The unit displayed will be €; rounded to 2 digits and multiplied by 1000.
    When the value reaches 10, the value displayed will be 10 k€.

    {
        "measures": {
            "turnover": {
                "unit": "€",
                 "round": 2,
                 "mult": 1000,
                 "pows": [
                   " ",
                  " k",
                  " M",
                  " G"
                ],
                "short": 3
            }
        }
    }
    Warning

    Measure format will be automatically applied by all Charts on field turnover included in an Analytics Manager request.
    You may also use it through code in your own components :

    import { FpMeasure } from 'forepaas/formatter'
    function formatValue(field, value) {
        let measure = new FpMeasure(field);
        return measure.setValue(value).toString();
    }
    console.log(formatValue("turnover", 100));
    

    dimensions

    Description: Allows you to indicate the nature of the data used for axes.

    OptionDescriptionTypeValues
    type Data typenull; string- null
    - temporal
    subtypeData subtypestring- year
    - month
    - quarter
    - semester
    - date
    - datetime
    - month-year
    - week-year
    formatFormatting to applystringMultiples

    Example:

    {
        "dimensions": {
            "sample_year": {
                "type": "temporal",
                "subtype": "year",
                "format": "YYYY"
            },
            "sample_month": {
                "type": "temporal",
                "subtype": "month",
                "format": "MM"
            },
            "sample_date": {
                "type": "temporal",
                "subtype": "date",
                "format": "DD/MM/YYYY"
            }
        }
    }
    Warning

    Dimension format will be automatically used by Chart components for scale rendering in general and X-axis specifically.