2
Could you help me in the case below?
I’m trying to change the color of the chart to red, but the change isn’t working.
Code:
function Devolucao() {
if (CicloAtual != "") {
var codCli = $("[id$=txtCodigo]").val();
var ciclos = Array();
var valores = Array();
var sucesso = false; //Variavel auxiliar, para verificar se o gráfico será preenchido para exibir uma mensagem de alerta caso não haja dado
$.ajax({
type: "POST",
url: "clientes.aspx/CarregarDevolucao",
data: "{'codCli': '" + codCli + "','Ciclo': '" + CicloAtual + "'}",
contentType: "application/json",
dataType: "json",
success: function (data) {
sucesso = true;
for (var i = 0; i < data.d.length; i++) {
ciclos[i] = data.d[i].string1.substring(4, 6) + "/" + data.d[i].string1.substring(0, 4);
valores[i] = parseFloat(data.d[i].string2.replace(",", "."));
}
var buyerData = {
labels: [ciclos[0], ciclos[1], ciclos[2], ciclos[3], ciclos[4], ciclos[5], ciclos[6], ciclos[7]],
datasets: [{
fillColor: "rgba(178,34,34)",
strokeColor: "#8B0000",
pointColor: "#8B0000",
pointStrokeColor: "#9DB86D",
data: [valores[0], valores[1], valores[2], valores[3], valores[4], valores[5], valores[6], valores[7]],
label: "Devolução"
}]
}
// get line chart canvas
var buyers = document.getElementById('buyers2').getContext('2d');
// draw line chart
new Chart(buyers, {
type: "line",
data: buyerData,
});
//new Chart(buyers).Line(buyerData);
document.getElementById("grafico1").style.display = 'block';
$('#ctl00_ContentPlaceHolder1_lblAviso').attr('style', "display:none;");
//montarvelocimetro(valores[7], CicloAtual);
}
})
if (!sucesso) {
$('#ctl00_ContentPlaceHolder1_lblAviso').attr('style', "display:block;");
}
}
}
There was no change either...
– Igor Carreiro
Includes an executable example (scroll to the end). Also includes the property backgroundColor and it worked.
– Alexandre Cavaloti