我试图在每列中加上百分比计算。我怎么能这样做?
我现在有这个:
var legend = new AmCharts.AmLegend();
chart.addLegend(legend);
var qtd = 0;
var sum = 0;
for(i=0;i<datas.length;i++){
sum[i] += Object.keys(datas[i]);
qtd = (qtd < Object.keys(datas[i]).length - 1) ? Object.keys(datas[i]).length - 1 : qtd;
}
console.log(Object.keys(datas));
for(j=1;j<qtd+1;j++){
datas[j].share = Math.round(datas[j].expenses / sum * 100);
var graph = new AmCharts.AmGraph();
graph.valueField = "expenses"+(j);
graph.balloonText = "[[category]]: <b>[[value]]</b> ([[share]]%)";
graph.labelText = "[[share]]%";
graph.labelPosition = "inside";
graph.type = "column";
graph.fillAlphas = 0.8;
chart.addGraph(graph);
}