amcharts.getCategoryName(rawData: Object): String
Returns the name of a field that represents a category in the data for the chart.
The category is chosen as follows:
slice.rows is chosen as the category.slice.rows array is empty and the slice.columns array contains some fields, the first field from slice.columns is chosen as the category.slice.rows and slice.columns arrays are empty, then no category is available.| Parameter/Type | Description |
|---|---|
| rawData Object | Raw data that contains the category. Check out the structure of rawData. |
A string with a category name or null when no category is available.
1) Setting the categoryField for the pie series:
am5percent.PieSeries.new(root, {
categoryField: pivot.amcharts.getCategoryName(rawData),
// ...
});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
}));
Setting the name for the amCharts 4 category axis:
let categoryAxis = chart.xAxes.push(new am4charts.CategoryAxis());
categoryAxis.dataFields.category = pivot.amcharts.getCategoryName(rawData);