amcharts / amcharts4

The most advanced amCharts charting library for JavaScript and TypeScript apps.
https://www.amcharts.com/
1.16k stars 321 forks source link

formatting Pie Chart label to only show one decimal #4313

Closed JonasEriksson closed 1 year ago

JonasEriksson commented 1 year ago

Question

I wish to display a value of 23.55% as 23.6% in the circular label around a PieChart section.

I am using Norwegian number formatting (basically, as all western European countries, this means the thousands separator is a space (or dot ( . ) ) and the decimals are separated by a "comma" ( , ) instead of a point/dot ( . ).

This is my current instruction which does not seem to work:

root.numberFormatter.setAll({
    numberFormat: "##,#",
    numericFields: ["valueY"]
});

(also tried "set(..." as well as "value" and "valueY,valueX" - that might not make sense, but I tried).

this is the code that hold the values:

// Create chart
    var chart = root.container.children.push(
        am5percent.PieChart.new(root, {
            layout: root.verticalLayout,
            endAngle: 270,
            radius: am5.percent(85),
            innerRadius: am5.percent(70) // make it a donut
        })
    );

        // Set data
        series0.data.setAll([{
            value: 23.45,
            category: "OPEX"
        },
        {
            value: 3.67</cfoutput>,
            category: "CAPEX"
        }]);

using TailwindCSS for CSS styling otherwise, but nothing that would affect amCharts.

Thanks for ideas! decimals-amCharts

martynasma commented 1 year ago

If this is about amCharts 5, please use appropriate repo.