All documentation
  • API Reference for older versions
  • amcharts.getCategoryName

    amcharts.getCategoryName(rawData: Object)

    Returns the name of a field that represents a category in data for the chart.

    Parameters

    Parameter/TypeDescription
    rawData
    Object
    Raw data that contains the category (check out the structure of rawData in getData()).

    Returns

    Returns a string, which is the name of a field representing a category in the chart's data.

    Examples

    amCharts 5

    1) Setting the categoryField for pie series:

    am5percent.PieSeries.new(root, {
      categoryField: pivot.amcharts.getCategoryName(rawData),
      // ...
    })

    See the full code on JSFiddle.

    2) Setting the categoryField for the Category axis in a radar chart:

    let xAxis = chart.xAxes.push(am5xy.CategoryAxis.new(root, {
      categoryField: pivot.amcharts.getCategoryName(rawData),
      renderer: xRenderer
    }));

    See an example on JSFiddle.

    amCharts 4

    Setting the name for the amCharts 4 Category axis:

    let categoryAxis = chart.xAxes.push(new am4charts.CategoryAxis());
    categoryAxis.dataFields.category = pivot.amcharts.getCategoryName(rawData);

    See the full code on JSFiddle.

    See also

    amcharts.getData
    amcharts.getMeasureNameByIndex
    amcharts.getNumberOfMeasures
    amcharts.getNumberFormatPattern