Get Free Trial
API reference
Table of contents

amcharts.getNumberOfMeasures

amcharts.getNumberOfMeasures(rawData: Object)

Returns the total number of available measures in the slice.

This method can be used to create a chart with multiple series (e.g., the stacked column chart). 

Parameters

amcharts.getNumberOfMeasures() has the following parameters:

  • rawData – Object. Raw data containing the measures to count (check out the structure of rawData in getData()).

Returns

Returns a number representing the quantity of measures in the slice.

Example

Here is an example of creating a 100% stacked column chart with amcharts.getNumberOfMeasures():

for (let s = 0; s < pivot.amcharts.getNumberOfMeasures(rawData); s++) {
    let series = chart.series.push(new am4charts.ColumnSeries());
    series.dataFields.categoryX = pivot.amcharts.getCategoryName(rawData);
    series.dataFields.valueY = pivot.amcharts.getMeasureNameByIndex(rawData, s);
    series.name = pivot.amcharts.getMeasureNameByIndex(rawData, s);
    series.stacked = true;
}

See the full code on JSFiddle.

See also

amcharts.getData
amcharts.getCategoryName
amcharts.getMeasureNameByIndex
amcharts.getNumberFormatPattern