porAntecipacao: function () {
var formData = tabDashboard.getFormData();
$.ajax({
type: "POST",
url: urlBase + '/TotalAntecipado',
divLoading: '#graficoPizzaPorAntecipacaoBarra',
cache: false,
async: true,
crossDomain: true,
processData: false,
contentType: false,
xhrFields: {
withCredentials: true
},
data: formData,
success: resposta => {
if (resposta.sucesso) {
var valores = [];
jQuery.each(resposta.dados.lista,
function (name, value) {
valores.push([value.pickNome, value.totalValorSolicitado]);
});
var chart2 = c3.generate({
bindto: '#graficoPizzaPorAntecipacaoBarra',
data: {
columns: valores,
type: 'bar'
},
bar: {
width: {
ratio: 1
}
},
axis: {
x: {
type: 'category'
}
},
tooltip: {
format: {
value: function (value, ratio, id) {
return value;
}
}
}
});
}
},
});
},
我需要将其格式化为BRL货币格式,我通过后端接收 公共十进制totalValorSolicitado { get;放; } 公共字符串totalValorSolicitadoFormatado { 获取;放; }
totalValorSolicitadoFormatado 采用 BRL 格式,但图表不接受此字符串格式。有人知道我能做什么吗?
我不知道这是图表接受的格式,还是我做错了什么。
axis: {
x: {
type: 'category'
},
y: {
tick: {
format: function (d) {
var formatar = new Intl.NumberFormat('pt-BR', {
style: 'currency',
currency: 'BRL'
});
return formatar.format(d);
}
}
}
tooltip: {
format: {
value: function (value, ratio, id) {
var formatar = new Intl.NumberFormat('pt-BR', {
style: 'currency',
currency: 'BRL'
});
return formatar.format(value);
}
}
有效