Need a special offer?Find out if your project fits.
+
All documentation
API reference
  • API Reference for older versions
  • amcharts.getNumberFormatPattern

    amcharts.getNumberFormatPattern(format: FormatObject)

    Converts the FormatObject to the amCharts number formatting string.

    To learn how the number format is set in amCharts, see the Using Flexmonster number formatting in amCharts section.

    Parameters

    Parameter/Type Description
    format
    FormatObject
    Contains the number format set in the component.

    Returns

    This method returns a string representing the amCharts number formatting string. For example: '$'#,###.00|'($'#,###.00')'.

    Examples

    amCharts 5

    Applying the formatting to the root element:

    root = am5.Root.new("amcharts-container");
    root.numberFormatter.set(
      "numberFormat",
      pivot.amcharts.getNumberFormatPattern(rawData.meta.formats[0])
    );

    See a live example on JSFiddle.

    amCharts 4

    Applying the formatting to the chart's Value axis and tooltip:

    // Get a FormatObject from Flexmonster
    let numberFormat = pivot.amcharts
                       .getNumberFormatPattern(rawData.meta.formats[0]);
    
    // Applying the formatting to the Value axis
    valueAxis.numberFormatter = new am4core.NumberFormatter();
    valueAxis.numberFormatter.numberFormat = numberFormat;
    
    // ...
    
    // Applying the formatting to the chart's tooltip
    series.tooltipText = 
      '{name}: [bold]{valueY.value.formatNumber("' + numberFormat + '")}[/]';

    See an example on JSFiddle.

    See also

    amcharts.getData
    amcharts.getCategoryName
    amcharts.getMeasureNameByIndex
    amcharts.getNumberOfMeasures