我的代码中有这个奇怪的错误。 当我使用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来获取数据,我应该注意它在图表上看起来很好。 如何解决这个问题以显示实际百分比?
答案 0 :(得分:1)
这不起作用,[[百分比]]显示一个系列图表的百分比,所以只有你有多个图表才有意义。在您的情况下,您应手动计算百分比值,将它们添加到您的数据,使用一些自定义字段名称,如“percentntsCalculated”,然后在标签中显示此值:[[percentntsCalculated]]