Documentation menu


webdatarocks.amcharts.getNumberOfMeasures(rawData: Object): Number

Returns the total number of measures that are specified in the data slice.

The common use case is to use this method in a for-loop when creating multiple series for a certain type of chart. Often used together with the amcharts.getMeasureNameByIndex() method.


1) Here is an example of how to configure the series for a stacked bar chart using amcharts.getNumberOfMeasures(), amcharts.getMeasureNameByIndex(), and amcharts.getCategoryName():

/* Create and configure series for a stacked bar chart */
for (s = 0; s < pivot.amcharts.getNumberOfMeasures(rawData); s++) {
	var series = chart.series.push(new am4charts.ColumnSeries());
	series.dataFields.valueX = pivot.amcharts.getMeasureNameByIndex(rawData, s);
	series.dataFields.categoryY = pivot.amcharts.getCategoryName(rawData);
	series.stacked = true; = pivot.amcharts.getMeasureNameByIndex(rawData, s);
	var labelBullet = series.bullets.push(new am4charts.LabelBullet());
	labelBullet.locationX = 0.5;
	labelBullet.label.text = "{valueX}";
	labelBullet.label.fill = am4core.color("#fff");

See the full code on CodePen.

See also