Closed Swaraj55 closed 1 year ago
It's not a bug, it's applying formatting from the smallNumberPrefixes
property for 1e-3, which is m
. You can modify the array if you don't want it applied, just like you did for bigNumberPrefixes
.
chart.numberFormatter.numberFormat = "#.00a"; chart.numberFormatter.bigNumberPrefixes = [ { "number": 1e+3, "suffix": "K" }, { "number": 1e+6, "suffix": "M" }, { "number": 1e+9, "suffix": "G" }, { "number": 1e+12, "suffix": "T" }, { "number": 1e+15, "suffix": "P" }, { "number": 1e+18, "suffix": "E" }, { "number": 1e+21, "suffix": "Z" }, { "number": 1e+24, "suffix": "Y" } ];
I did it but still got 800.00m.
I need to use smallNumberPrefixes?
For smaller numbers, yes you do.
But I don't want 'm' (500.00m) should come with a label. It simply displays '0.5' on the label.
In my case, the data should be 0 or maybe in thousands, millions, and billions.
As I mentioned in my prior comment, you have to modify the smallNumberPrefixes
array to account for the smaller values. If you don't want smallNumberPrefixes
to trigger, just empty the array. You already modified bigNumberPrefixes
in your initial post for thousands, millions and billions, so just add a line for the other property to handle decimal values < 1.
chart.numberFormtter.smallNumberPrefixes = []; //prevent labels from being applied to decimal values < 1
Does that make sense?
Thanks, xorspark.
It's work
In this Screenshot what is the meaning of 500m?
Below I share one example. It is a bug or what because expect the 0.5? /**
*/
am4core.useTheme(am4themes_animated);
// Create chart instance var chart = am4core.create("chartdiv", am4charts.XYChart);
// Add data chart.data = [{ "category": "Research", "value": 1 }, { "category": "Marketing", "value": 1 }, { "category": "Distribution", "value": 1 }];
// Configure number formatter chart.numberFormatter.numberFormat = "#a"; chart.numberFormatter.bigNumberPrefixes = [ { "number": 1e+3, "suffix": "K" }, { "number": 1e+6, "suffix": "M" }, { "number": 1e+9, "suffix": "B" } ];
// Create axes var categoryAxis = chart.xAxes.push(new am4charts.CategoryAxis()); categoryAxis.dataFields.category = "category"; categoryAxis.renderer.grid.template.location = 0; //categoryAxis.renderer.minGridDistance = 30;
var valueAxis = chart.yAxes.push(new am4charts.ValueAxis());
// Create series var series = chart.series.push(new am4charts.ColumnSeries()); series.dataFields.valueY = "value"; series.dataFields.categoryX = "category";