我有一个莫里斯条形图和 json 数据。Json 数据返回两个带有角度 foreach 的数据,如下所示:
data:[
{y:'01', a:25 ,b:45},
{y:'02', a:35 ,b:65}
]
“y”是“xkey”,表示月份,“01”=一月,“02”=二月。所以我想在 xlabel 中显示所有月份,并且只获取活动的数据。
我如何使用角度 foreach 和月份名称来做到这一点?
代码:
function barChart() {
window.barChart = Morris.Bar({
element: 'bar-chart',
data: PeriodData,
xkey: 'y',
ykeys: ['a', 'b'],
labels: ['Toplam Ciro', 'Toplam Paket'],
postUnits: ' TL',
lineColors: ['#1e88e5', '#ff3321'],
lineWidth: '3px',
xLabelAngle: 60,
resize: true,
redraw: true,
hoverCallback: function(index, options, content, row) {
var indexb = 2;
var txtToReplace = $(content)[indexb].textContent;
return content.replace(txtToReplace, txtToReplace.replace(options.postUnits, ""));
}
});
}
和周期数据;
angular.forEach(data, function(value, index) {
PeriodData.push({
y: data[index][dateType.toUpperCase()],
a: data[index].TOTAL_CIRO,
b: data[index].DELIVERY_TOTAL});
});