当我使用[[percents]时,amcharts上的错误在每列中显示100.00%

Bug on amcharts shows 100.00% in every column when i use [[percents]]

本文关键字:错误 显示 amcharts percents      更新时间:2023-09-26

我的代码中有这个奇怪的错误。当我使用amcharts并试图显示每列的百分比时,每列都是100.00%。

AmCharts.ready(function () {
    $.ajax({
        url: 'Analytics/GetDivergenceByApp?appid=46',
        type: 'POST',
        contentType: 'application/json;',
        //data: JSON.stringify({ id: checkId }),
        success: function run(dataset) {
            // RADAR CHART
            chart = new AmCharts.AmSerialChart();
            chart.dataProvider = dataset;
            chart.categoryField = "col";
            chart.startDuration = 1;
            chart.sequencedAnimation = false;

            var categoryAxis = chart.categoryAxis;
            categoryAxis.gridPosition = "start";
            // VALUE AXIS
            var valueAxis = new AmCharts.ValueAxis();
            valueAxis.axisAlpha = 0.15;
            valueAxis.minimum = 0;
            valueAxis.dashLength = 3;
            valueAxis.stackType = "regular";
            chart.addValueAxis(valueAxis);

            // GRAPH
            var graph = new AmCharts.AmGraph();
            graph.type = "column";
            graph.labelText = "[[percents]]%";
            graph.valueField = "value";
            graph.title = "All Pushes";
            graph.fillAlphas = 0.6;
            graph.balloonText = "[[value]] os type installations";
            chart.addGraph(graph);
            // WRITE
            chart.write("chartdiv2");
        }
    });
});

我使用C#和MVC4来获取数据,我应该注意它在图表上看起来很好。我该如何修复它以显示实际百分比?

这不起作用,[[percents]]显示一个系列的图的百分比,因此只有当您有多个图时,这才有意义。在您的情况下,您应该手动计算百分比值,将它们添加到您的数据中,并使用一些自定义字段名称,如"percentsCalculated",然后在标签中显示此值:[[percentsCCalculated]]