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).
Parameter/Type | Description |
---|---|
rawData Object | Raw data containing the measures to count (check out the structure of rawData in getData()). |
Returns a number representing the quantity of measures in the slice.
Using amcharts.getNumberOfMeasures()
to create a stacked column chart:
for (let s = 0; s < pivot.amcharts.getNumberOfMeasures(rawData); s++) { let series = chart.series.push(am5xy.ColumnSeries.new(root, { name: pivot.amcharts.getMeasureNameByIndex(rawData, s), xAxis: xAxis, yAxis: yAxis, stacked: true, valueYField: pivot.amcharts.getMeasureNameByIndex(rawData, s), categoryXField: pivot.amcharts.getCategoryName(rawData), })); series.data.setAll(data); }
See the full code on JSFiddle.
Using amcharts.getNumberOfMeasures()
to create a stacked column chart:
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.
amcharts.getData
amcharts.getCategoryName
amcharts.getMeasureNameByIndex
amcharts.getNumberFormatPattern